Note: Change parameter values as needed.
packer build \
-var 'aws_region=us-east-1' \
-var 'aws_vpc_id=<vpc-id>' \
-var 'vpc_subnet_id=<subnet-id>' \
-var 'ec2_temp_sg_ip_cidr=<ip-cidr>' \
-var 'ec2_instance_type=t4g.micro' \
-var 'ami_arch=arm64' \
amz-linux2-latest-ami-httpd.json
Test the httpd server:
http://<ec2-public-ip>
Note: Change parameter values as needed.
packer build \
-var 'aws_region=us-east-1' \
-var 'aws_source_ami=<ami-id>' \
-var 'aws_vpc_id=<vpc-id>' \
-var 'vpc_subnet_id=<subnet-id>' \
-var 'ec2_instance_type=t2.micro' \
-var 'ec2_temp_sg_ip_cidr=<ip-cidr>' \
amz-linux2-ami-lamp.json
Test the lamp server:
http://<ec2-public-ip>/phpinfo.php
packer build \
-var 'aws_region=us-east-1' \
-var 'aws_source_ami=<ami-id>' \
-var 'aws_vpc_id=<vpc-id>' \
-var 'vpc_subnet_id=<subnet-id>' \
-var 'ec2_instance_type=t2.micro' \
-var 'ec2_temp_sg_ip_cidr=<ip-cidr>' \
amz-linux2-ami-custom-storage.json
packer build \
-var 'aws_region=us-east-1' \
-var 'aws_source_ami=<ami-id>' \
-var 'aws_vpc_id=<vpc-id>' \
-var 'vpc_subnet_id=<subnet-id>' \
-var 'ec2_instance_type=t2.micro' \
-var 'ec2_temp_sg_ip_cidr=<ip-cidr>' \
amz-linux2-ami-multiple-vol.json
https://www.packer.io/docs/builders/amazon/ebs
https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeImages.html
https://aws.amazon.com/blogs/mt/creating-packer-images-using-system-manager-automation/
For querying the latest AMI, refer to below link for owners list:
For volume block device mapping details, refer to below links:
https://www.packer.io/docs/builders/amazon/ebs#ami_block_device_mappings
https://www.packer.io/docs/builders/amazon/ebs#block-devices-configuration