variablesにaws_profileを宣言し、環境変数(env)から取得するようにします。
builderのprofileにその変数を使うように指定します。
{
"min_packer_version": "1.4.2",
"variables": {
"aws_region": "ap-northeast-1",
"aws_profile": "{{env `AWS_PROFILE`}}"
},
"builders": [
{
"profile": "{{user `aws_profile`}}"
}
]
}
実行
AWS_PROFILE=sandbox packer build ファイル