1
votes

I have created an instance with instance profile associated. I am trying to run packer on the instance without using access and secret key, hence I am using the profile option.

However, the packer requires a profile name, but the instance profile doesn't create a profile name and also doesn't create credentials under ~/.aws.

I can see the access and secret key associated via the AWS CLI, however it doesn't have a profile name.

[ec2-user@ip-172-31-19-132 ~]$ aws configure list
      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                <not set>             None    None
access_key     ****************3IO2         iam-role
secret_key     ****************cFvD         iam-role
    region           ap-southeast-2             imds

As I understand from this answer, access and secret keys are rotated frequently, I am wondering how can I set the profile name to the credentials permanently, so I can refer that in packer.

1

1 Answers

2
votes

There won't be a profile name as you're using an IAM role. Instead you should natively use the IAM role instead.

Finally, Packer will use credentials provided by the task's or instance's IAM role, if it has one.

This is a preferred approach over any other when running in EC2 as you can avoid hard coding credentials. Instead these are leased on-the-fly by Packer, which reduces the chance of leakage.

Remove the references to the profile option, and it should just natively work just like the SDK / CLI functionality would.