3 回答
- 最新
- 投票最多
- 评论最多
2
Hello. You can use this step inside your github actions.
- name: Create AMI
run: |
INSTANCE_ID="YOUR_INSTANCE_ID" # replace with your instance's ID
AMI_NAME="MyApp-$(date +'%Y-%m-%d-%H-%M-%S')"
# Create AMI
IMAGE_ID=$(aws ec2 create-image --instance-id $INSTANCE_ID --name "$AMI_NAME" --description "An AMI for MyApp" --no-reboot --query 'ImageId' --output text)
echo "AMI ID: $IMAGE_ID"
Regards, Andrii
1
If you want to create an AMI automatically whenever you make updates to an EC2 instance, you can take several approaches.
Using AWS Systems Manager (SSM) AWS Systems Manager allows you to automate tasks across AWS resources. You can use Systems Manager Run Command to automate the creation of AMIs.
Trigger with CloudWatch Events AWS CloudWatch Events can be used to detect changes in your EC2 instances and then trigger the Systems Manager Run Command.
Because it`s not possible to integrate GitHub action to automatically create an AMI.
Regards, Andrii
相关内容
- AWS 官方已更新 6 个月前
- AWS 官方已更新 4 个月前
Hi Andrii S, thanks I got that as well. But now I have one more question I need to create this AMI only if there are some updates on the server. For e.g. installed two more DLLs or software. How can we acknowledge that and create an AMI with the updates?