This repository has been archived by the owner on Jun 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy path08_custom-resources.yml
53 lines (47 loc) · 1.91 KB
/
08_custom-resources.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
AWSTemplateFormatVersion: "2010-09-09"
Description: "DynamoDB zip codes and cities"
Resources:
DynamoDbTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: zip # declare zip as a string
AttributeType: S
KeySchema:
- AttributeName: zip # declare zip as the partition key (hash)
KeyType: HASH
BillingMode: "PAY_PER_REQUEST"
PrepopualateTable: # this key is arbitrary
#Type: AWS::CloudFormation::CustomResource # could use generic form
Type: Custom::LambdaPrepopulateTable # using semantic form
DependsOn: DynamoDbTable
Properties:
# an Amazon SNS topic ARN or Lambda function ARN
ServiceToken: !Sub arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:prepop-dynamodb
# arbitary key:values here
TableARN: !GetAtt DynamoDbTable.Arn
# CloudFormation REQUEST (http) or EVENT (lambda) will look something like this:
# {
# "RequestType" : "Create",
# "ResponseURL" : "http://pre-signed-S3-url-for-response",
# "StackId" : "arn:aws:cloudformation:us-west-2:EXAMPLE/stack-name/guid",
# "RequestId" : "unique id for this create request",
# "ResourceType" : "Custom::LambdaPrepopulateTable",
# "LogicalResourceId" : "PrepopualateTable",
# "ResourceProperties" : {
# "TableARN" : "{dervied table arn}"
# }
# }
# Our lamba function's RESPONSE will look something like this:
#
# {
# "Status" : "SUCCESS",
# "PhysicalResourceId" : "TestResource1",
# "StackId" : "arn:aws:cloudformation:us-west-2:EXAMPLE:stack/stack-name/guid",
# "RequestId" : "unique id for this create request",
# "LogicalResourceId" : "PrepopualateTable",
# "Data" : {
# "OutputName1" : "Value1",
# "OutputName2" : "Value2",
# }
# }