Skip to content

Commit

Permalink
feat: support other AWS regions and move location
Browse files Browse the repository at this point in the history
  • Loading branch information
sammarks committed Jul 22, 2020
1 parent 95dda43 commit 4cd4185
Show file tree
Hide file tree
Showing 4 changed files with 4,441 additions and 2,231 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ event (Lambda function, Email, Text Message, etc) at a specific time.

It's simple! Click this fancy button:

[![Launch Stack](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/new?stackName=scheduled-tasks&templateURL=https://cloudformation-scheduled-tasks.s3.amazonaws.com/template.yaml)
[![Launch Stack](https://s3.amazonaws.com/cloudformation-examples/cloudformation-launch-stack.png)](https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/new?stackName=scheduled-tasks&templateURL=https://sammarks-cf-templates.s3.amazonaws.com/scheduled-tasks/template.yaml)

Then give the stack a name, and configure it:

Expand Down Expand Up @@ -88,7 +88,7 @@ otherTopic:
scheduledTasksStack:
Type: AWS::CloudFormation::Stack
Properties:
TemplateURL: https://cloudformation-scheduled-tasks.s3.amazonaws.com/VERSION/template.yaml
TemplateURL: https://sammarks-cf-templates.s3.amazonaws.com/scheduled-tasks/VERSION/template.yaml
Parameters:
PollingSchedule: 'rate(5 minutes)'
ReadCapacityUnits: 1
Expand Down Expand Up @@ -121,6 +121,20 @@ resources:
otherResource: # ... all of your original resources
```

**A quick note on regions:** If you are deploying this stack in a region other than `us-east-1`,
you need to reference the proper region S3 bucket as we're deploying Lambda functions. Just
add the region suffix to the template URL, so this:

```
https://sammarks-cf-templates.s3.amazonaws.com/scheduled-tasks/VERSION/template.yaml
```

becomes this:

```
https://sammarks-cf-templates-us-east-2.s3.amazonaws.com/scheduled-tasks/VERSION/template.yaml
```

### What's deployed?

- Two Lambda Functions (Schedule and Ingest)
Expand Down
21 changes: 16 additions & 5 deletions deploy-to-s3.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
rm -f ./sam-template.yaml ./packaged-template.yaml
rm -f ./packaged-template.yaml ./sam-template.yaml

sls sam export --output ./sam-template.yaml

PACKAGE_VERSION=$(node -p -e "require('./package.json').version")

# us-east-1
aws cloudformation package \
--template-file ./sam-template.yaml \
--s3-bucket cloudformation-scheduled-tasks \
--s3-bucket sammarks-cf-templates \
--output-template-file packaged-template.yaml
aws s3 cp ./packaged-template.yaml "s3://sammarks-cf-templates/scheduled-tasks/$PACKAGE_VERSION/template.yaml"
aws s3 cp ./packaged-template.yaml "s3://sammarks-cf-templates/scheduled-tasks/template.yaml"

PACKAGE_VERSION=$(node -p -e "require('./package.json').version")
aws s3 cp ./packaged-template.yaml "s3://cloudformation-scheduled-tasks/$PACKAGE_VERSION/template.yaml"
aws s3 cp ./packaged-template.yaml "s3://cloudformation-scheduled-tasks/template.yaml"
# us-east-2
aws cloudformation package \
--template-file ./sam-template.yaml \
--s3-bucket sammarks-cf-templates-us-east-2 \
--output-template-file packaged-template.yaml
aws s3 cp ./packaged-template.yaml "s3://sammarks-cf-templates-us-east-2/scheduled-tasks/$PACKAGE_VERSION/template.yaml"
aws s3 cp ./packaged-template.yaml "s3://sammarks-cf-templates-us-east-2/scheduled-tasks/template.yaml"

rm -rf ./packaged-template.yaml ./sam-template.yaml
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@
"deploy": "./deploy-to-s3.sh"
},
"devDependencies": {
"aws-sdk": "^2.504.0",
"aws-sdk-mock": "^4.5.0",
"coveralls": "^3.0.5",
"eslint": "^6.1.0",
"eslint-config-standard": "^13.0.1",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jest": "^22.14.1",
"eslint-plugin-node": "^9.1.0",
"aws-sdk": "^2.717.0",
"aws-sdk-mock": "^5.1.0",
"coveralls": "^3.1.0",
"eslint": "^7.5.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^23.18.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"jest": "^24.8.0",
"jest-junit": "^7.0.0",
"lolex": "^4.2.0",
"serverless": "^1.49.0",
"eslint-plugin-standard": "^4.0.1",
"jest": "^26.1.0",
"jest-junit": "^11.0.1",
"lolex": "^6.0.0",
"serverless": "^1.75.1",
"serverless-sam": "^0.2.0",
"standard-version": "^7.0.0"
"standard-version": "^8.0.2"
},
"resolutions": {
"lodash": "4.17.15"
"lodash": "4.17.19"
}
}
Loading

0 comments on commit 4cd4185

Please sign in to comment.