Code Monkey home page Code Monkey logo

aws-cloudformation-stack-resource's Introduction

AWS CloudFormation Stack Resource

A Concourse resource to manage your AWS CloudFormation stacks.

Source Configuration

  • name - the stack name
  • access_key - AWS access key
  • secret_key - AWS secret key
  • region - the region to manage the stack (default us-east-1)

Behavior

check

Trigger when the stack is successfully created or updated.

in

Pulls down stack outputs, resource IDs, and metadata.

  • /arn.txt - the stack ARN
  • /outputs.json - a JSON object with the stack outputs
  • /resources.json - a JSON object with the logical IDs of all created resources (resource name + Id is the key). Names of security groups are also set (resource name + Name)

Parameters:

  • allow_deleted - by default the resource will fail when referencing a deleted stack (default false)

out

Create, update, or delete the stack. The parameters and tags data should by a simple key-value hash of names and values (e.g. {"MyName":"MyValue"}).

  • template - path to a CloudFormation template (do not configure when enabling delete)
  • parameters - path to a JSON file
  • parameters_aws - path to a aws cloudformation formatted JSON file
  • tags - path to a JSON file
  • capabilities - array of additional capabilities (e.g. CAPABILITY_IAM)
  • delete - set to true to delete the stack (default false)

Installation

This resource is not included with the standard Concourse release. Use one of the following methods.

Deployment-wide

To install on all Concourse workers, update your deployment manifest to add a new resource_types...

properties:
  groundcrew:
    resource_types:
      - image: "docker:///dpb587/aws-cloudformation-stack-resource#stable"
        type: "aws-cloudformation-stack"

Pipeline-specific

To use on a single pipeline, update your pipeline to add a new resource_types...

resource_types:
  - name: "aws-cloudformation-stack"
    type: "docker-image"
    source:
      repository: "dpb587/aws-cloudformation-stack-resource"
      tag: "stable"

Example

The following example uses a repository to store configuration and, whenever the repository is updated, the stack will be created/updated according to template or parameter changes. Another job watches the stack for changes and will execute a hook to propagate stack results and resources to dependent services.

resources:
  # a stack we will be updating
  - name: "acme-stack"
    type: "aws-cloudformation-stack"
    source:
      name: "my-acme-stack-name"
      access_key: "my-aws-access-key"
      secret_key: "my-aws-secret-key"
  
  # a repository to version your configuration
  - name: "acme-config"
    type: "git-resource"
    source:
      repository: "[email protected]:infra.git"

jobs:
  # update the stack when changes are made in your repo
  - name: "update-prod-stack"
    plan:
      - get: "acme-config"
        trigger: true
      - put: "acme-stack"
        params:
          template: "acme-infra/vpc/template.json"
          parameters: "acme-infra/vpc/generate-parameters.sh"
  
  # execute a hook whenever the stack is created/updated
  # propagate task will see `stack/arn.txt`, `stack/outputs.json`, ...
  - name: "propagate-resources"
    plan:
      - aggregate:
          - get: "stack"
            resource: "acme-stack"
            trigger: true
          - get: "acme-config"
      - task: "propagate"
        file: "acme-config/vpc/post-update-hooks.yml"

Another example is the main pipeline which creates/updates/deletes a stack as part of some lightweight tests.

aws-cloudformation-stack-resource's People

Contributors

cunnie avatar dpb587 avatar dsabeti avatar mmb avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

aws-cloudformation-stack-resource's Issues

Create Upstream PR

After a bit more testing and migrating a few more pipelines to use this. Probably make a PR description along the lines of...


Hi - I forked this repo a few weeks ago to start adding check/in support, but then eventually ended up kind of rewriting the repo to support them and expand features. I'm sending this PR more to share the results, not to obligate you to merge - I know "rewrites" are often unhelpful. Certainly happy to discuss what could make this mergeable though. Here's a summary of the changes...

  • source config
    • renamed, moved out.stack_name to be the resource-level property name - seemed a more appropriate location and also now used by check/in scripts
    • renamed aws_access_key, aws_secret_key to just access_key, secret_key - simpler and since the resource is already AWS-specific it seemed implied
  • version reference was replaced from {"ref":"...sha1..."} to be {"arn":"...arn...","time":"...ISO8601..."} - sha1 breaks pipelines if templates are reverted, doesn't include parameters, and also needs to cover the cases where a stack is fully replaced since new resources will be created
  • out
    • new delete parameter to support the delete-stack operation - I wanted support for some short-lived stacks for test deployments
    • added parameters, tags support to point to key-value JSON files - some of my existing stacks utilize stack parameters
  • in - new
    • dumps out the ARN, any stack outputs, and any created resource IDs - my deployments often reference resources like security groups, subnets, and IAM profiles that are managed by stacks
    • if a stack has changed since it was initially triggered, it will error
    • if a stack is deleted, it will error (configurable since some pipelines may want to know about this)
  • check - new
    • whenever the ARN or update time of the stack changes, it triggers
  • testing - added a self-testing pipeline - builds/publishes a resource container and then goes through the process of creating and destroying a stack with it before promoting the branch and image through
  • docker - switched away from boosh in favor of simple shell; this dropped the go requirements, so I switched to the base image of alpine for smaller images (827MB/277MB -> 91MB/37MB, uncompressed/compressed)

screen shot 2016-03-29 at 12 38 37 am

Anyways, not sure if it's helpful or not to the project. Happy to discuss.

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.