i am using packer version 1.5.5 and trying to create AMI on AWS but getting an below error:
" Build ‘amazon-ebs’ errored: error validating regions: AuthFailure: AWS was not able to validate the provided access credentials
status code: 401, request id: a06b49b4-4ee1-42c6-99a5-7cd9f62d3387"
i have already exported the aws secret, access and the region on the packer node. is there anything which i am missing.
in aws i am able to create the AMI using the same account which i am using in the packer json.
Could you post your packer file?
{
“variables”: {
“aws_access_key”: “{{ env QqMRGAQXXXXXXXX
}}”,
“aws_secret_key”: “{{ env 'XXXXXMRGAQwbpxxxxAKIAQUzNV8xxxxxxx` }}”,
“ssh_username”: “ec2-user”,
“base_ami”: “ami-07579xxxx3234”,
“instance_type”: “t2.small”,
“subnet_id”: “subnet-c4a723434”
},
“provisioners”: [
{
“type”: “ansible”,
“playbook_file”: “./root/script.yml”,
“user”: “ec2-user”,
“extra_arguments”: [ “-vvvv” ]
}
],
“builders”: [
{
“type”: “amazon-ebs”,
“access_key”: “{{ user aws_access_key
}}”,
“secret_key”: “{{ user aws_secret_key
}}”,
“region”: “us-east-1”,
“source_ami”: “{{user base_ami
}}”,
“instance_type”: “{{user instance_type
}}”,
“ssh_username”: “{{user ssh_username
}}”,
“ssh_keypair_name”: “automation”,
“ssh_private_key_file”: “/root/automation.pem”,
“subnet_id”: “{{user subnet_id
}}”,
“ami_name”: “packer-image-{{timestamp}}”,
“associate_public_ip_address”: true,
“tags”: {
“Name”: “Packer-image”
}
}
]
}
I am able to resolve this error by performing the below steps:
yum install ntp -y
service ntpd stop
ntpdate time.nist.gov
service ntpd start
hope it helps to other people facing the same issue.
1 Like