From 1de3d9a6995cd4eb0372bf23307f10ee73c6f238 Mon Sep 17 00:00:00 2001 From: dtomlinson Date: Mon, 27 Apr 2020 20:09:55 +0100 Subject: [PATCH] updating notes --- runningnotes.md | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ todo.md | 4 +-- 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/runningnotes.md b/runningnotes.md index 6c2a6cc..9ce51f5 100644 --- a/runningnotes.md +++ b/runningnotes.md @@ -1,3 +1,5 @@ +# Running notes + create an elb with --single and --database redeploy with username option set, does it change? @@ -171,3 +173,75 @@ An example is: } } ``` + +## Cloudformation + + (example of deploying an S3 bucket with static site `index.html`.) + +To create a cloudformation template you should create a `template.yaml`. This yaml file should have at the top: + +```yaml +AWSTemplateFormatVersion: 2010-09-09 +Description: A simple CloudFormation template +``` + +Then you should add a `Resources` key and populate this with all the infrastructure you need to provision. + +### Creating templates + +Documentation for all AWS resources is: . + +A good approach is to use the GUI to create an object, and then lookup the cloudformation template as you go along. + +### Deploy a stack/template + +To deploy, you should run the command: `aws cloudformation deploy --template-file template.yaml --stack-name static-website` + +### Failure + +If something goes wrong, you can use `describe-stack-events` and pass the `stack-name` to find the events leading up to the failure: `aws cloudformation describe-stack-events --stack-name strapi-s3`. + +If this is the first time you are creating a stack you will not be able to re-deploy the stack. You must first delete the stack entirely and then re-deploy with any fixes. + +You can delete a stack by running: `aws --profile admin cloudformation delete-stack --stack-name strapi-s3`. + +### Stacks + + + +A cloudformation stack is a collection of AWS resources that you can manage as a single unit. You can group different resources under one stack then create, update or destroy everything under this stack. + +Using stacks means AWS will treat all resources as a single unit. They must all be created or destroyed successfully to be created or deleted. If a resource cannot be created, Cloudformation will roll the stack back to the previous configuration and delete any interim resources that were created. + +### Snippets + +#### Deploy a template/stack + +`aws --profile admin cloudformation deploy --template-file ./01-stack-storage.yaml --stack-name strapi-s3` + +#### Destroy a stack + +`aws --profile admin cloudformation delete-stack --stack-name strapi-s3` + +## Tags + +Suggested tags for all AWS resources are: + +| Tag | Description | Example | +| ----------- | ---------------------------------- | ------------------------ | +| git | git repo that contains the code | `web-dev` | +| owner | who the resource is for/owned | `home`, `work`, `elliot` | +| project | what project it belongs to | `strapi-elb` | +| test | flag for a temporary test resource | `true` | +| environment | environment resource belongs to | `dev`, `prod` | +| deployment | AWS tool used for deployment | `cloudformation`, `elb` | + +### Cloudformation + +For Cloudformation resources the following tags get applied automatically: + +| Tag | Description | Example | +| ----------------------------- | ------------------------------- | -------------------------------------------------------------------------------------------------- | +| aws:cloudformation:stack-name | stack-name of the resource | `strapi-s3` | +| aws:cloudformation:logical-id | resource name given in template | `ELBExampleBucket` | +| aws:cloudformation:stack-id | ARN of the cloudformation stack | arn:aws:cloudformation:eu-west-1:745437999005:stack/strapi-s3/459ebbf0-88aa-11ea-beac-02f0c9b42810 | diff --git a/todo.md b/todo.md index 27f67e5..c547d5c 100644 --- a/todo.md +++ b/todo.md @@ -1,7 +1,7 @@ # To Do -Finish S3 config for env vars -Deploy to AWS and ensure vars are working +~~Finish S3 config for env vars~~ +~~Deploy to AWS and ensure vars are working~~ Use cloudformation to deploy bucket instead of tieing it to the RDS instance. Use for bucket options for the template.