Giter Club home page Giter Club logo

aws-cloudformation-starter-workflow-for-github-actions's Introduction

AWS CloudFormation Starter Workflow for GitHub Actions

This template repository contains a sample application and sample GitHub Actions workflow files for continuously deploying both application code and infrastructure as code with GitHub Actions.

The sample application is a simple containerized web application that uses Amazon ECS on AWS Fargate behind a public Application Load Balancer (ALB). The application is split up into two CloudFormation stacks:

  1. infrastructure.yml deploys the infrastructure resources (for example, the ALB and the ECS cluster)
  2. service.yml deploys the application code (for example, the ECS task definition and ECS service)

This repository contains two starter workflow files for GitHub Actions:

  1. check.yml runs when a pull request is opened or updated. This workflow validates that the web application Docker image builds successfully with the proposed code changes.
  2. deploy.yml runs when a new commit is pushed to the master branch. This workflow deploys both the infrastucture CloudFormation stack and the application CloudFormation stack.

Create a GitHub repository from this template

Click the "Use this template" button above to create a new repository from this template.

Clone your new repository, and deploy the IAM resources needed to enable GitHub Actions to deploy CloudFormation templates:

aws cloudformation deploy \
  --stack-name github-actions-cloudformation-deploy-setup \
  --template-file cloudformation-templates/setup.yml \
  --capabilities CAPABILITY_NAMED_IAM \
  --region us-east-2

You can review the permissions that your repository's GitHub Actions deployment workflow will have in the setup.yml CloudFormation template.

Retrieve the IAM access key credentials that GitHub Actions will use for deployments:

aws secretsmanager get-secret-value \
  --secret-id github-actions-cloudformation-deploy \
  --region us-east-2 \
  --query SecretString \
  --output text

Create two GitHub Actions secrets for the access key in your GitHub repository by going to Settings > Secrets. Alternatively, you can create these GitHub Actions secrets at the GitHub organization level, and grant access to the secrets to your new repository.

  1. Create a secret named AWS_ACCESS_KEY_ID containing the AccessKeyId value returned above.
  2. Create a secret named AWS_SECRET_ACCESS_KEY containing in the SecretAccessKey value returned above.

Go to the Actions tab, select the latest workflow run and its failed job, then select "Re-run jobs" > "Re-run all jobs".

When the workflow successfully completes, expand the "Print service URL" step in the "Deploy web application" job to see the URL for the deployed web application.

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

aws-cloudformation-starter-workflow-for-github-actions's People

Contributors

amazon-auto avatar clareliguori avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.