Giter Club home page Giter Club logo

forms's Introduction

Create a new application named "myNewApp" based on the "blue" Stack Template:

1. Create change set:

	var AWS = require('aws-sdk');
	AWS.config.update({region: 'us-east-2'});
	var cloudformation = new AWS.CloudFormation();

	var params = {
		ChangeSetName: "blueV1",
		ChangeSetType: "CREATE"
		StackName: "myNewApp",
		TemplateURL: "https://s3.amazonaws.com/cloudformations-014066636401/cloudformations/stacks/blue.yaml",
		Capabilities: ["CAPABILITY_NAMED_IAM"]
	};
	cloudformation.createChangeSet(params, function(err, data) {
		if (err) console.log(err, err.stack); // an error occurred
		else     console.log(data);           // successful response
	});

2. View change set:

	var AWS = require('aws-sdk');
	AWS.config.update({region: 'us-east-2'});
	var cloudformation = new AWS.CloudFormation();

	var params = {
		ChangeSetName: "blueV1",
		StackName: "myNewApp"
	};
	cloudformation.describeChangeSet(params, function(err, data) {
		if (err) console.log(err, err.stack); // an error occurred
		else     console.log(data);           // successful response
	});

	If you review the request from the AWS Cloudformations console, the "myNewApp" 
	stack will remain in a "Reviewing" state until the changes are implemented by 
	the execute-change-set command.

3. Execute change set:

	var AWS = require('aws-sdk');
	AWS.config.update({region: 'us-east-2'});
	var cloudformation = new AWS.CloudFormation();

	var params = {
		ChangeSetName: "blueV1",
		StackName: "myNewApp"
	};
	cloudformation.executeChangeSet(params, function(err, data) {
		if (err) console.log(err, err.stack); // an error occurred
		else     console.log(data);           // successful response
	});

Update an existing application w/ different or updated Stack Template:

1. Update change set:

	var AWS = require('aws-sdk');
	AWS.config.update({region: 'us-east-2'});
	var cloudformation = new AWS.CloudFormation();

	var params = {
		ChangeSetName: "blueV2",
		ChangeSetType: "UPDATE"
		StackName: "myNewApp",
		TemplateURL: "https://s3.amazonaws.com/cloudformations-014066636401/cloudformations/stacks/blue.yaml",
		Capabilities: ["CAPABILITY_NAMED_IAM"]
	};
	cloudformation.createChangeSet(params, function(err, data) {
		if (err) console.log(err, err.stack); // an error occurred
		else     console.log(data);           // successful response
	});

2. View change set:

	var AWS = require('aws-sdk');
	AWS.config.update({region: 'us-east-2'});
	var cloudformation = new AWS.CloudFormation();

	var params = {
		ChangeSetName: "blueV2",
		StackName: "myNewApp"
	};
	cloudformation.describeChangeSet(params, function(err, data) {
		if (err) console.log(err, err.stack); // an error occurred
		else     console.log(data);           // successful response
	});

	If you review the request from the AWS Cloudformations console, the "myNewApp" 
	stack will remain in a "Reviewing" state until the changes are implemented by 
	the execute-change-set command.	

3. Execute change set:

	var AWS = require('aws-sdk');
	AWS.config.update({region: 'us-east-2'});
	var cloudformation = new AWS.CloudFormation();

	var params = {
		ChangeSetName: "blueV2",
		StackName: "myNewApp"
	};
	cloudformation.executeChangeSet(params, function(err, data) {
			if (err) console.log(err, err.stack); // an error occurred
			else     console.log(data);           // successful response
	});

Resource Templates

Independent cloudformation templates that deploy a single AWS service

Repo location: ./resorces/*

Example:

	./resources/sqs.yaml

	AWSTemplateFormatVersion: '2010-09-09'
	Description: sqs
	Resources:
	  sqs:
	    Type: "AWS::SQS::Queue"
	    
	Outputs:
	  sqsArn:
	    Value: !GetAtt sqs.Arn
	  sqsName:
	    Value: !GetAtt sqs.QueueName

Transforms

Parameters of the Resource Templates that are included from any external s3 bucket. 
These could be defined by a developer or security team..etc and sourced during deployment. 

Repo location: ./transforms/*

Example:

	./transforms/lambda.yaml

	MemorySize: 1024
	ZipFile: console.log("hello world and goodbye")
	Timeout: 25
	Mode: Active

Stack Templates

A grouping of Resource Templates working together for a single application. 
Upon a Stack update, an changes within any of the independant Resource Templates or external Transform files
are applied to the overall Stack(s).

Repo location ./stacks/*

Example:

	./stacks/blue.yaml

	AWSTemplateFormatVersion: '2010-09-09'
	Description: A Blue Stack Application

	Resources:

	  role:
	    Type: "AWS::CloudFormation::Stack"
	    Properties:
	      TemplateURL: "https://s3.amazonaws.com/cloudformations-014066636401/cloudformations/resources/role.yaml"
	      TimeoutInMinutes: 2
	      Parameters:
		'Fn::Transform':
		  Name: 'AWS::Include'
		  Parameters:
		    Location: "s3://cloudformations-014066636401/cloudformations/transforms/role.yaml"

	  loggroup:
	    Type: "AWS::CloudFormation::Stack"
	    Properties:
	      TemplateURL: "https://s3.amazonaws.com/cloudformations-014066636401/cloudformations/resources/loggroup.yaml"
		      TimeoutInMinutes: 2

		  lambda:
		    Type: "AWS::CloudFormation::Stack"
		    DependsOn:
		      - role
		    Properties:
		      TemplateURL: "https://s3.amazonaws.com/cloudformations-014066636401/cloudformations/resources/lambda.yaml"
		      TimeoutInMinutes: 2
		      Parameters:
			roleArn: 
			  Fn::GetAtt: [role, Outputs.roleArn]
			'Fn::Transform':
			  Name: 'AWS::Include'
			  Parameters:
			    Location: "s3://cloudformations-014066636401/cloudformations/transforms/lambda.yaml"

			...etc

forms's People

Contributors

larkinrobert avatar

Watchers

 avatar  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.