Skip to content

quick and dirty container via docker for use in aws codebuild + aws pipelines for building AMIs (POC)

Notifications You must be signed in to change notification settings

brian-provenzano/aws-codebuild-alpine-container

Repository files navigation

AWS Codebuild Docker Build Container Using Alpine Linux

Basic Alpine image build environment needed to create AWS AMIs per this POC project/repo [aws-codebuild-packer-poc](https://github.com/brian-provenzano/aws-codebuild-packer-poc

Ingredients

  • alpine:latest as base image
  • python3, wget, git, jq, awscli, python, requests
  • My hashicorp-get script to retrieve latest packer
  • get-ami.sh to grab image ID of newly built AMI (via packer postprocessor in aws codebuild). See packer template
  • cleanup-ami.sh - cleans up old versions of AMIs (deregisters AMI, deletes associated snapshots).

Note: See Codebuild buildspec.yaml for usage details

Policies

The following policies need to be added to the codebuild service role:

Update

Now using AWS codebuild to build the docker image. Changed buildspec.yaml (aws codebuild) to version 0.2 in order to get around the following. I didnt realize version 0.1 was executing each command in an isolated subshell.

You can specify any Shell command. In build spec version 0.1, AWS CodeBuild runs each Shell command in a separate instance in the build environment. This means that each command runs in isolation from all other commands. Therefore, by default, you cannot run a single command that relies on the state of any previous commands (for example, changing directories or setting environment variables). To get around this limitation, we recommend that you use version 0.2, which solves this issue. 

https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-cmd.html

Thanks

Hashicorp AWS

About

quick and dirty container via docker for use in aws codebuild + aws pipelines for building AMIs (POC)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published