Reputation: 125
I need to prepare an AMI based on CentOS 8 with pre-installed SSM-agent. Trying to use Image Builder for this. According to the documentation:
Instances used to build images and run tests using Image Builder must have access to the Systems Manager service. All build activity is orchestrated by SSM Automation. The SSM Agent will be installed on the source image if it is not already present, and it will be removed before the image is created.
So the question is how to prevent removing of SSM-agent? I need to keep it installed. Unfortunately couldn't find a solution in the documentation.
Upvotes: 6
Views: 4084
Reputation: 1
In Cloudformation you can add this option to your image recipe.
Recipe:
Type: AWS::ImageBuilder::ImageRecipe
Properties:
AdditionalInstanceConfiguration:
SystemsManagerAgent:
UninstallAfterBuild: false
Upvotes: 0
Reputation: 11
At least with Debian AMI the path is /root/image-builder, not /tmp/imagebuilder_service. Please also note that nowdays EC2Imagebuilder contains option to keep agent installed after image is created.
If you are using terraform, just set following option:
systems_manager_agent {
uninstall_after_build = false
}
Upvotes: 1
Reputation: 388
ImageBuilder installs the SSM agent if SSM is not present in the source AMI and uninstalls the agent before taking the AMI.
When ImageBuilder installs the SSM agent, it keeps track of the installation of the agent(in a file) and it is located at/tmp/imagebuilder_service/ssm_installed
.
you just need to remove that file as part of your build, then it won't remove the SSM agent.
Add an extra step in the Imagebuilder build component to retain the SSM agent installation
- name: RetainSSMAgentInstallation
action: ExecuteBash
inputs:
commands:
- sudo rm -rf /tmp/imagebuilder_service/ssm_installed
Upvotes: 8