diff --git a/buildspec.yml b/buildspec.yml index 5609c65..b7c5348 100644 --- a/buildspec.yml +++ b/buildspec.yml @@ -5,7 +5,7 @@ phases: runtime-versions: python: 3.11 commands: - - echo "Installing Python version 3.11 ... + - echo "Installing Python version 3.11 ..." - pyenv global $PYTHON_311_VERSION - echo "Installing Ansible ..." - pip3 install ansible @@ -13,4 +13,9 @@ phases: commands: - echo "Building with Packer ..." - packer init build.pkr.hcl - - packer build -var project_name=rhel-arm-image-pipeline-demo -var ansible_dir=${CODEBUILD_SRC_DIR}/ansible build.pkr.hcl \ No newline at end of file + - packer build -var project_name=rhel-arm-image-pipeline-demo -var ansible_dir=${CODEBUILD_SRC_DIR}/ansible build.pkr.hcl + post_build: + commands: + - echo "Saving AMI ID ..." + - packer build -machine-readable build.pkr.hcl | tee >(grep 'artifact,0,id' | cut -d, -f6 | cut -d: -f2 > ami_id.txt) + - test -s ami_id.txt || exit 1 \ No newline at end of file diff --git a/modules/image-pipeline/build.pkr.hcl b/modules/image-pipeline/build.pkr.hcl index ffc5da8..ad15649 100644 --- a/modules/image-pipeline/build.pkr.hcl +++ b/modules/image-pipeline/build.pkr.hcl @@ -2,7 +2,7 @@ source "amazon-ebs" "rhel" { ami_name = "rhel-arm-{{timestamp}}" instance_type = "t4g.micro" region = "us-gov-west-1" - source_ami = "ami-0ce8fc041db68907c" + source_ami = "ami-06ac1fe9004042996" ssh_username = "ec2-user" }