Skip to content

Commit

Permalink
[Improvement] state/dynamodb - Support optional stream (widdix#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwittig authored Jun 5, 2019
1 parent f4d0d1d commit df2d652
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ install:
- 'pip install cfn-lint==0.21.3'
script:
- 'yamllint .'
- 'cfn-lint -i E3002 W2001 W6001 -t ''**/*.yaml''' # TODO get rid of check ignores
- 'cfn-lint -i E3002 W2001 W6001 W2030 -t ''**/*.yaml''' # TODO get rid of check ignores
- 'find . -type f -name ''*.yaml'' | while read file; do set -ex && grep -q "LICENSE-2.0" "$file"; done;'
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then find . -type f -name ''*.yaml'' | while read file; do set -ex && aws s3 cp "$file" "s3://travis-aws-cf-templates/$TRAVIS_COMMIT/$file" && aws cloudformation validate-template --template-url "https://s3.amazonaws.com/travis-aws-cf-templates/$TRAVIS_COMMIT/$file" > /dev/null; done; fi'
16 changes: 16 additions & 0 deletions state/dynamodb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ Metadata:
- MaxReadCapacityUnits
- MinReadCapacityUnits
- ReadCapacityUnitsUtilizationTarget
- Encryption
- TimeToLiveAttributeName
- StreamViewType
Parameters:
ParentAlertStack:
Description: 'Optional but recommended stack name of parent alert stack based on operations/alert.yaml template.'
Expand Down Expand Up @@ -100,13 +102,19 @@ Parameters:
Description: 'Optional name of the Time to Live attribute used to store the expiration time (unix timestamp in seconds)'
Type: String
Default: ''
StreamViewType:
Description: 'Determines the information that the stream captures when an item in the table is modified.'
Type: String
Default: DISABLED
AllowedValues: [DISABLED, KEYS_ONLY, NEW_IMAGE, OLD_IMAGE, NEW_AND_OLD_IMAGES]
Conditions:
HasAlertTopic: !Not [!Equals [!Ref ParentAlertStack, '']]
HasSortKey: !Not [!Equals [!Ref SortKeyName, '']]
HasTableName: !Not [!Equals [!Ref TableName, '']]
HasAwsManagedEncryption: !Equals [!Ref Encryption, aws]
HasBillingAndScalingModeProvisioned: !Equals [!Ref BillingAndScalingMode, PROVISIONED]
HasTimeToLiveAttributeName: !Not [!Equals [!Ref TimeToLiveAttributeName, '']]
HasStream: !Not [!Equals [!Ref StreamViewType, 'DISABLED']]
Resources:
Table:
Type: 'AWS::DynamoDB::Table'
Expand All @@ -133,6 +141,7 @@ Resources:
SSESpecification:
SSEEnabled: !If [HasAwsManagedEncryption, true, false]
TimeToLiveSpecification: !If [HasTimeToLiveAttributeName, {AttributeName: !Ref TimeToLiveAttributeName, Enabled: true}, !Ref 'AWS::NoValue']
StreamSpecification: !If [HasStream, {StreamViewType: !Ref StreamViewType}, !Ref 'AWS::NoValue']
RoleScaling:
Condition: HasBillingAndScalingModeProvisioned
Type: 'AWS::IAM::Role'
Expand Down Expand Up @@ -313,3 +322,10 @@ Outputs:
TableName:
Description: 'Name of the table'
Value: !Ref Table
Export:
Name: !Sub '${AWS::StackName}-TableName'
StreamArn:
Condition: HasStream
Value: !GetAtt 'Table.StreamArn'
Export:
Name: !Sub '${AWS::StackName}-StreamArn'

0 comments on commit df2d652

Please sign in to comment.