Unable to use AWS Marketplace AMI to build packer image

Dear Team,

I’m trying to create a packer build image by using a source ami from AWS Market Place (CentOS/RHEL) image available on AWS cloud.
I’m unable to proceed further as it threw below error.

2020/11/06 11:52:41 packer-builder-amazon-ebs plugin: Using AMI Filters {
2020/11/06 11:52:41 packer-builder-amazon-ebs plugin: Filters: [{
2020/11/06 11:52:41 packer-builder-amazon-ebs plugin: Name: “root-device-type”,
2020/11/06 11:52:41 packer-builder-amazon-ebs plugin: Values: [“ebs”]
2020/11/06 11:52:41 packer-builder-amazon-ebs plugin: },{
2020/11/06 11:52:41 packer-builder-amazon-ebs plugin: Name: “virtualization-type”,
2020/11/06 11:52:41 packer-builder-amazon-ebs plugin: Values: [“hvm”]
2020/11/06 11:52:41 packer-builder-amazon-ebs plugin: },{
2020/11/06 11:52:41 packer-builder-amazon-ebs plugin: Name: “name”,
2020/11/06 11:52:41 packer-builder-amazon-ebs plugin: Values: [“CentOS Linux 7 x86_64 HVM EBS 1708_11.01-b7ee8a69-ee97-4a49-9e68-afaee216db2e-ami-95096eef.4”]
2020/11/06 11:52:41 packer-builder-amazon-ebs plugin: }],
2020/11/06 11:52:41 packer-builder-amazon-ebs plugin: Owners: [“679593333241”]
2020/11/06 11:52:41 packer-builder-amazon-ebs plugin: }
amazon-ebs: Found Image ID: ami-82a3eaed
2020/11/06 11:52:41 packer-builder-amazon-ebs plugin: [INFO] Finding AZ and VpcId for the given subnet ‘subnet-0c1ca677’
==> amazon-ebs: Using existing SSH private key
2020/11/06 11:52:42 packer-builder-amazon-ebs plugin: [INFO] AvailabilityZone found: ‘ap-south-1c’
==> amazon-ebs: Creating temporary security group for this instance: packer_5fa4ebb2-bf12-4751-780f-a33a096e636e
2020/11/06 11:52:43 packer-builder-amazon-ebs plugin: [DEBUG] Waiting for temporary security group: sg-0f1bb33e96671158c
2020/11/06 11:52:44 packer-builder-amazon-ebs plugin: [DEBUG] Found security group sg-0f1bb33e96671158c
==> amazon-ebs: Authorizing access to port 22 from [0.0.0.0/0] in the temporary security groups…
==> amazon-ebs: Launching a source AWS instance…
==> amazon-ebs: Adding tags to source instance
amazon-ebs: Adding tag: “Name”: “Packer Builder”
==> amazon-ebs: Error launching source instance: OptInRequired: In order to use this AWS Marketplace product you need to accept terms and subscribe. To do so please visit https://aws.amazon.com/marketplace/pp?sku=aw0evgkw8e5c1q413zgy5pjce
==> amazon-ebs: status code: 401, request id: ff1c7308-4215-48af-9212-cb2e2503c136
==> amazon-ebs: No volumes to clean up, skipping
==> amazon-ebs: Deleting temporary security group…
==> amazon-ebs: status code: 401, request id: ff1c7308-4215-48af-9212-cb2e2503c136
2020/11/06 11:52:46 [INFO] (telemetry) ending amazon-ebs
Build ‘amazon-ebs’ errored: Error launching source instance: OptInRequired: In order to use this AWS Marketplace product you need to accept terms and subscribe. To do so please visit https://aws.amazon.com/marketplace/pp?sku=aw0evgkw8e5c1q413zgy5pjce
status code: 401, request id: ff1c7308-4215-48af-9212-cb2e2503c136

==> Some builds didn’t complete successfully and had errors:
–> amazon-ebs: Error launching source instance: OptInRequired: In order to use this AWS Marketplace product you need to accept terms and subscribe. To do so please visit https://aws.amazon.com/marketplace/pp?sku=aw0evgkw8e5c1q413zgy5pjce

Could anyone suggest me to resolve this error?

Regards,
Guru Mohan G

Different Marketplace AMIs have different default login credentials. If you’re using this one: https://aws.amazon.com/marketplace/pp/Centosorg-CentOS-7-x8664-with-Updates-HVM/B00O7WM7QW

then the docs on that page say

Starting with CentOS-7 we now include cloud-init support in all CentOS AMI’s, the default cloud user is setup to be ‘centos’. Once the machine is running, you will be able to login as this user and use sudo to run privileged commands. You can override this default username by using instance user data at time of instantiation.

So, set username to centos and leave password blank.