Useful commands and examples for AWS CLI
Last active
March 26, 2024 21:27
-
-
Save rtomyj/17b41c27600d4ea414a20ca94ffa2e1d to your computer and use it in GitHub Desktop.
AWS CLI - Useful Commands
Components are used by Image Builder Recipes in order to setup the software envrioment.
In short, a component installs sofware for an AMI.
Developers can either choose to preset components, use components shared by others, or create their own custom components
aws imagebuilder list-componentsWhen you have the desired ARN (for the specific component and version) from above command, you can get the info of the component using the following command
aws imagebuilder get-component --component-build-version-arn ${ARN}In particualr, it is important to be able to get the yaml configuration associated to a particular component/version
aws imagebuilder get-component --query component.data --component-build-version-arn ${ARN} --output textAn exmaple of a yaml configuration for a component can be seen below.
The component
- will update packages installed by yum package manager
- download docker
- download docoker-compose (using default version - else calling receipe can specify a version)
- ensure docker is started as a service - ensures it stays up when users logoff
name: DockerSetup
description: Install docker and docker-compose
schemaVersion: 1.0
parameters:
- DockerComposeVersion:
type: string
default: "2.26.0"
description: Version of docker compose to install
phases:
- name: build
steps:
- name: UpdateDependencies
action: ExecuteBash
inputs:
commands:
- yum update -y
- name: InstallDocker
action: ExecuteBash
inputs:
commands:
- sudo dnf install docker -y
- name: InstallDockerCompose
action: ExecuteBash
inputs:
commands:
- sudo curl -L "https://github.com/docker/compose/releases/download/v{{ DockerComposeVersion }}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- sudo chmod +x /usr/local/bin/docker-compose
- name: RunDockerService
action: ExecuteBash
inputs:
commands:
- sudo service docker start
- sudo usermod -a -G docker ec2-user
- name: validate
steps:
- name: ValidateInstall
action: ExecuteBash
inputs:
commands:
- docker --version
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment