diff --git a/Makefile b/Makefile index 2d4e471c..c7564f22 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,29 @@ -.PHONY: all lint test +REGION ?= us-west-2 +ENV ?= stage +ARGS ?= --interactive -all: lint test +.PHONY: all lint test build + +all: lint test build + +# run one time only +prerequisite: + sudo python setup.py install lint: flake8 stacker_blueprints test: python setup.py test + +build: + stacker build --region ${REGION} ${ARGS} conf/${ENV}.env conf/example.yaml + +diff: + stacker diff --region ${REGION} ${ARGS} conf/${ENV}.env conf/example.yaml + +info: + stacker info --region ${REGION} ${ARGS} conf/${ENV}.env conf/example.yaml + +destroy: + stacker destroy --region ${REGION} ${ARGS} conf/${ENV}.env conf/example.yaml diff --git a/README.md b/README.md new file mode 100644 index 00000000..02ab16c6 --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +stacker_blueprints +================== + +[![circleci](https://circleci.com/gh/cloudtools/stacker_blueprints.svg?style=shield)](https://circleci.com/gh/cloudtools/stacker_blueprints) +[![pypi package](https://badge.fury.io/py/stacker_blueprints.svg)](https://badge.fury.io/py/stacker_blueprints) +[![slack](https://empire-slack.herokuapp.com/badge.svg)](https://empire-slack.herokuapp.com) + +An attempt at a common Blueprint library for use with [stacker](https://github.com/cloudtools/stacker). + +# Quick start + +>NOTES: it will create aws resources and generate cost on your aws account. `make destroy` them all if not required any more. + +If you're new to stacker you may use [stacker_cookiecutter](https://github.com/cloudtools/stacker_cookiecutter) to setup your project. + +1) Make sure you [set up authentication credentials to access aws](http://boto3.readthedocs.io/en/latest/guide/quickstart.html#configuration) + +2) Review files [conf/stage.env](conf/stage.env) and [conf/example.yaml](conf/example.yaml) + +3) Adjust namespace in [conf/stage.env](conf/stage.env) to a global unique name + +### Build the stacks + +Build full stacks (vpc, bastion, myDB, myWeb) + + $ git clone https://github.com/cloudtools/stacker_blueprints.git + $ cd stacker_blueprints + $ make build + + # If you have other environment files, such as prod.env + $ make build ENV=prod + + # If you want to create stacks in other region + $ make build REGION=ap-southeast-2 + +### Other commands + + $ make info + $ make diff + $ make destroy + +### Try other examples + +There are examples under folder `conf`, for example, you want to run test on rds stack, you can easily play with below command + + stacker build --region us-west-2 conf/rds/mysql.env conf/rds/mysql.yaml diff --git a/conf/example.yaml b/conf/example.yaml index d926559f..93230f97 100644 --- a/conf/example.yaml +++ b/conf/example.yaml @@ -57,7 +57,7 @@ stacks: - name: bastion class_path: stacker_blueprints.bastion.Bastion enabled: true - parameters: + variables: # Extends the parameters dict with the contents of the vpc_parameters # anchor. Basically we're including all VPC Outputs in the parameters # of the bastion stack. Note: Stacker figures out, automatically, which @@ -77,7 +77,7 @@ stacks: # stack name "myDB" on the command line with --force locked: true enabled: true - parameters: + variables: << : *vpc_parameters InstanceType: db.m3.medium AllocatedStorage: 10 @@ -93,7 +93,7 @@ stacks: - name: myWeb class_path: stacker_blueprints.asg.AutoscalingGroup enabled: true - parameters: + variables: << : *vpc_parameters InstanceType: m3.medium ImageName: ubuntu1404 diff --git a/conf/stage.env b/conf/stage.env index 8f181313..bde0ca28 100644 --- a/conf/stage.env +++ b/conf/stage.env @@ -6,4 +6,4 @@ # will be used to prefix the CloudFormation stack names as well as the s3 # bucket that contains revisions of the stacker templates. This is the only # required environment variable. -namespace: +namespace: stacker_blueprints