-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(storage): Add dynamoDB Cloudformation templates (#993)
<!-- Provide summary of changes --> This PR adds the cloudformation template necessary to create DDB tables on behalf of customers in storage init. <!-- Issue number, if available. E.g. "Fixes #31", "Addresses #42, 77" --> Addresses #769 By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
- Loading branch information
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{{.TableResourceName}}: | ||
Type: AWS::DynamoDB::Table | ||
DeletionPolicy: Retain | ||
Properties: | ||
TableName: !Sub ${App}-${Env}-${Name}-{{.TableName}} | ||
AttributeDefinitions: | ||
- AttributeName: {{.Name}} | ||
AttributeType: "{{.DataType}}"{{end}} | ||
BillingMode: PAY_PER_REQUEST | ||
KeySchema: | ||
- AttributeName: {{.PartitionKey}} | ||
KeyType: HASH{{ if .SortKey }} | ||
- AttributeName: {{.SortKey}} | ||
KeyType: RANGE{{end}}{{if .HasLSI}} | ||
LocalSecondaryIndexes:{{range .LSIs}} | ||
- IndexName: {{.Name}} | ||
KeySchema: | ||
- AttributeName: {{.PartitionKey}} | ||
KeyType: HASH | ||
- AttributeName: {{.SortKey}} | ||
KeyType: RANGE | ||
Projection: | ||
ProjectionType: ALL{{end}}{{end}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{{.TableResourceName}}TableName: | ||
Description: "The name of this DynamoDB." | ||
Value: !Ref {{.TableResourceName}} | ||
{{.TableResourceName}}AccessPolicy: | ||
Description: "The IAM::ManagedPolicy to attach to the task role." | ||
Value: !Ref {{.TableResourceName}}AccessPolicy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{{.TableResourceName}}AccessPolicy: | ||
Type: AWS::IAM::ManagedPolicy | ||
Properties: | ||
Description: !Sub | ||
- Grants CRUD access to the Dynamo DB table ${Table} | ||
- { Table: !Ref {{.TableResourceName}} } | ||
PolicyDocument: | ||
Version: 2012-10-17 | ||
Statement: | ||
- Sid: DDBActions | ||
Effect: Allow | ||
Action: | ||
- dynamodb:BatchGet* | ||
- dynamodb:DescribeStream | ||
- dynamodb:DescribeTable | ||
- dynamodb:Get* | ||
- dynamodb:Query | ||
- dynamodb:Scan | ||
- dynamodb:BatchWrite* | ||
- dynamodb:Create* | ||
- dynamodb:Delete* | ||
- dynamodb:Update* | ||
- dynamodb:PutItem | ||
Resource: !Sub ${ {{.TableResourceName}}.Arn} | ||
- Sid: DDBLSIActions | ||
Action: | ||
- dynamodb:Query | ||
- dynamodb:Scan | ||
Effect: Allow | ||
Resource: !Sub ${ {{.TableResourceName}}.Arn}/Index/* |