Browse the Repo

file-type-icon.circleci
file-type-icon_ci
file-type-icon_docs
file-type-iconexamples
file-type-iconmodules
file-type-iconaws-helpers
file-type-iconbuild-helpers
file-type-iconcheck-url
file-type-iconcircleci-helpers
file-type-iconec2-backup
file-type-iconecs-deploy-runner-invoke-iam-policy
file-type-iconecs-deploy-runner-standard-configuration
file-type-iconecs-deploy-runner
file-type-icongit-helpers
file-type-icongruntwork-module-circleci-helpers
file-type-iconiam-policies
file-type-iconinfrastructure-deploy-script
file-type-iconinfrastructure-deployer
file-type-icondeploy
file-type-iconlogging
file-type-iconrevshlex
file-type-iconREADME.adoc
file-type-iconcore-concepts.md
file-type-icongo.mod
file-type-icongo.sum
file-type-iconmain.go
file-type-iconinstall-jenkins
file-type-iconjenkins-server
file-type-iconkubernetes-circleci-helpers
file-type-iconterraform-helpers
file-type-icontest
file-type-icontestdep
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME-CircleCI.adoc
file-type-iconREADME-Jenkins.adoc
file-type-iconREADME-Terraform-Terragrunt-Pipeline.adoc
file-type-iconREADME-TravisCI.adoc
file-type-iconREADME.adoc
file-type-iconsetup.cfg

Browse the Repo

file-type-icon.circleci
file-type-icon_ci
file-type-icon_docs
file-type-iconexamples
file-type-iconmodules
file-type-iconaws-helpers
file-type-iconbuild-helpers
file-type-iconcheck-url
file-type-iconcircleci-helpers
file-type-iconec2-backup
file-type-iconecs-deploy-runner-invoke-iam-policy
file-type-iconecs-deploy-runner-standard-configuration
file-type-iconecs-deploy-runner
file-type-icongit-helpers
file-type-icongruntwork-module-circleci-helpers
file-type-iconiam-policies
file-type-iconinfrastructure-deploy-script
file-type-iconinfrastructure-deployer
file-type-icondeploy
file-type-iconlogging
file-type-iconrevshlex
file-type-iconREADME.adoc
file-type-iconcore-concepts.md
file-type-icongo.mod
file-type-icongo.sum
file-type-iconmain.go
file-type-iconinstall-jenkins
file-type-iconjenkins-server
file-type-iconkubernetes-circleci-helpers
file-type-iconterraform-helpers
file-type-icontest
file-type-icontestdep
file-type-icon.gitignore
file-type-icon.pre-commit-config.yaml
file-type-iconCODEOWNERS
file-type-iconLICENSE.txt
file-type-iconREADME-CircleCI.adoc
file-type-iconREADME-Jenkins.adoc
file-type-iconREADME-Terraform-Terragrunt-Pipeline.adoc
file-type-iconREADME-TravisCI.adoc
file-type-iconREADME.adoc
file-type-iconsetup.cfg
EC2 backup

EC2 backup

Snapshot your EC2 instances on a scheduled basis.

Code Preview

Preview the Code

mobile file icon

core-concepts.md

down

Core Concepts

Overview

This module contains a CLI interface that can be used to trigger arbitrary infrastructure deployment (plan or apply) of remote infrastructure code stored in a git repository using the pipeline deployed with the ecs-deploy-runner module. This CLI will:

  • invoke the deployment Lambda function
  • wait until the deployment is complete
  • stream intermediate log output from the deployment until it is complete

Refer to the ecs-deploy-runner module documentation to learn more about the overal architecture of the deploy runner service.

Operations

How do I install the infrastructure-deployer CLI?

The infrastructure-deployer CLI is a single binary. The easiest way to get it into your CI environment is to use the Gruntwork Installer (make sure to replace <VERSION> below with the latest version from the releases page):

gruntwork-install --binary-name infrastructure-deployer --repo https://github.com/gruntwork-io/module-ci --tag <VERSION>

Alternatively, you can download the binary from the Releases Page.

What are the IAM permissions necessary to trigger a deployment from the infrastructure-deployer CLI?

You can use the ecs-deploy-runner-invoke-iam-policy module to create an IAM policy that grants the minimal permissions necessary to trigger a deployment, check the status of the deployment, and stream the logs from that deployment.

How do I invoke the ECS deploy runner?

The infrastructure-deployer command will invoke the corresponding lambda function with the args to run the provided script in the selected container with the given args. This command selects the lambda function to invoke based on the provided region (via the --aws-region CLI flag) and the lambda function name (via the --invoker-function-id CLI flag, which defaults to ecs-deploy-runner-invoker).

For example, to invoke a plan action against a standard ECS deploy runner deployed in us-west-2:

infrastructure-deployer --aws-region us-west-2 \
    -- terraform-planner infrastructure-deploy-script --binary terraform --command plan

This will run the command infrastructure-deploy-script --binary terraform --command plan in the container identified with terraform-planner on ECS Fargate by invoking the ECS deploy runner invoker lambda function that is deployed into us-west-2.

You can get the list of supported containers and their scripts by passing in the --describe-containers option. For example:

infrastructure-deployer --describe-containers --aws-region us-west-2

Running this command will provide output similar to below:

INFO[2020-08-17T10:00:44-05:00] The Lambda function arn:aws:lambda:ca-central-1:738755648600:function:7kr4n5-ecs-deploy-runner-gmvitx-invoker supports the following containers (container is in bold):  name=infrastructure-deployer
INFO[2020-08-17T10:00:44-05:00]   ami-builder                         name=infrastructure-deployer
INFO[2020-08-17T10:00:44-05:00]         build-packer-artifact                      name=infrastructure-deployer
INFO[2020-08-17T10:00:44-05:00]   docker-image-builder                name=infrastructure-deployer
INFO[2020-08-17T10:00:44-05:00]         build-docker-image                         name=infrastructure-deployer
INFO[2020-08-17T10:00:44-05:00]   terraform-applier                   name=infrastructure-deployer
INFO[2020-08-17T10:00:44-05:00]         infrastructure-deploy-script               name=infrastructure-deployer
INFO[2020-08-17T10:00:44-05:00]         terraform-update-variable                  name=infrastructure-deployer
INFO[2020-08-17T10:00:44-05:00]   terraform-planner                   name=infrastructure-deployer
INFO[2020-08-17T10:00:44-05:00]         infrastructure-deploy-script               name=infrastructure-deployer

Questions? Ask away.

We're here to talk about our services, answer any questions, give advice, or just to chat.

Ready to hand off the Gruntwork?