123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- AWSTemplateFormatVersion: "2010-09-09"
- Description: Amazon S3 Find and Forget DDB Tables
- Metadata:
- cfn-lint:
- config:
- ignore_checks:
- - W1001
- Parameters:
- EnableBackups:
- Type: String
- RetainTables:
- Type: String
- Conditions:
- ShouldNotRetainTables: !Equals [!Ref RetainTables, "false"]
- ShouldRetainTables: !Equals [!Ref RetainTables, "true"]
- Resources:
- # DeletionPolicy and UpdateReplacePolicy need a String
- # https://github.com/aws-cloudformation/aws-cloudformation-coverage-roadmap/issues/162
- DeletionQueueTableNotRetain:
- Type: AWS::DynamoDB::Table
- Condition: ShouldNotRetainTables
- DeletionPolicy: Delete
- UpdateReplacePolicy: Delete
- Properties:
- StreamSpecification:
- StreamViewType: NEW_IMAGE
- AttributeDefinitions:
- -
- AttributeName: DeletionQueueItemId
- AttributeType: S
- KeySchema:
- -
- AttributeName: DeletionQueueItemId
- KeyType: HASH
- BillingMode: PAY_PER_REQUEST
- PointInTimeRecoverySpecification:
- PointInTimeRecoveryEnabled: !Ref EnableBackups
- SSESpecification:
- KMSMasterKeyId: alias/aws/dynamodb
- SSEEnabled: true
- SSEType: KMS
- DeletionQueueTableRetain:
- Type: AWS::DynamoDB::Table
- Condition: ShouldRetainTables
- DeletionPolicy: Retain
- UpdateReplacePolicy: Retain
- Properties:
- StreamSpecification:
- StreamViewType: NEW_IMAGE
- AttributeDefinitions:
- -
- AttributeName: DeletionQueueItemId
- AttributeType: S
- KeySchema:
- -
- AttributeName: DeletionQueueItemId
- KeyType: HASH
- BillingMode: PAY_PER_REQUEST
- PointInTimeRecoverySpecification:
- PointInTimeRecoveryEnabled: !Ref EnableBackups
- SSESpecification:
- KMSMasterKeyId: alias/aws/dynamodb
- SSEEnabled: true
- SSEType: KMS
- DataMapperTableNotRetain:
- Type: AWS::DynamoDB::Table
- Condition: ShouldNotRetainTables
- DeletionPolicy: Delete
- UpdateReplacePolicy: Delete
- Properties:
- AttributeDefinitions:
- -
- AttributeName: DataMapperId
- AttributeType: S
- KeySchema:
- -
- AttributeName: DataMapperId
- KeyType: HASH
- BillingMode: PAY_PER_REQUEST
- PointInTimeRecoverySpecification:
- PointInTimeRecoveryEnabled: !Ref EnableBackups
- SSESpecification:
- KMSMasterKeyId: alias/aws/dynamodb
- SSEEnabled: true
- SSEType: KMS
- DataMapperTableRetain:
- Type: AWS::DynamoDB::Table
- Condition: ShouldRetainTables
- DeletionPolicy: Retain
- UpdateReplacePolicy: Retain
- Properties:
- AttributeDefinitions:
- -
- AttributeName: DataMapperId
- AttributeType: S
- KeySchema:
- -
- AttributeName: DataMapperId
- KeyType: HASH
- BillingMode: PAY_PER_REQUEST
- PointInTimeRecoverySpecification:
- PointInTimeRecoveryEnabled: !Ref EnableBackups
- SSESpecification:
- KMSMasterKeyId: alias/aws/dynamodb
- SSEEnabled: true
- SSEType: KMS
- JobTableNotRetain:
- Type: AWS::DynamoDB::Table
- Condition: ShouldNotRetainTables
- DeletionPolicy: Delete
- UpdateReplacePolicy: Delete
- Properties:
- TimeToLiveSpecification:
- AttributeName: Expires
- Enabled: true
- StreamSpecification:
- StreamViewType: NEW_AND_OLD_IMAGES
- AttributeDefinitions:
- -
- AttributeName: Id
- AttributeType: S
- -
- AttributeName: Sk
- AttributeType: S
- -
- AttributeName: GSIBucket
- AttributeType: S
- -
- AttributeName: CreatedAt
- AttributeType: N
- KeySchema:
- -
- AttributeName: Id
- KeyType: HASH
- -
- AttributeName: Sk
- KeyType: RANGE
- BillingMode: PAY_PER_REQUEST
- GlobalSecondaryIndexes:
- -
- IndexName: Date-GSI
- KeySchema:
- -
- AttributeName: GSIBucket
- KeyType: HASH
- -
- AttributeName: CreatedAt
- KeyType: RANGE
- Projection:
- ProjectionType: ALL
- PointInTimeRecoverySpecification:
- PointInTimeRecoveryEnabled: !Ref EnableBackups
- SSESpecification:
- KMSMasterKeyId: alias/aws/dynamodb
- SSEEnabled: true
- SSEType: KMS
- JobTableRetain:
- Type: AWS::DynamoDB::Table
- Condition: ShouldRetainTables
- DeletionPolicy: Retain
- UpdateReplacePolicy: Retain
- Properties:
- TimeToLiveSpecification:
- AttributeName: Expires
- Enabled: true
- StreamSpecification:
- StreamViewType: NEW_AND_OLD_IMAGES
- AttributeDefinitions:
- -
- AttributeName: Id
- AttributeType: S
- -
- AttributeName: Sk
- AttributeType: S
- -
- AttributeName: GSIBucket
- AttributeType: S
- -
- AttributeName: CreatedAt
- AttributeType: N
- KeySchema:
- -
- AttributeName: Id
- KeyType: HASH
- -
- AttributeName: Sk
- KeyType: RANGE
- BillingMode: PAY_PER_REQUEST
- GlobalSecondaryIndexes:
- -
- IndexName: Date-GSI
- KeySchema:
- -
- AttributeName: GSIBucket
- KeyType: HASH
- -
- AttributeName: CreatedAt
- KeyType: RANGE
- Projection:
- ProjectionType: ALL
- PointInTimeRecoverySpecification:
- PointInTimeRecoveryEnabled: !Ref EnableBackups
- SSESpecification:
- KMSMasterKeyId: alias/aws/dynamodb
- SSEEnabled: true
- SSEType: KMS
-
- Outputs:
- DeletionQueueTable:
- Value: !If
- - ShouldRetainTables
- - !Ref DeletionQueueTableRetain
- - !Ref DeletionQueueTableNotRetain
- DeletionQueueTableStreamArn:
- Value: !If
- - ShouldRetainTables
- - !GetAtt DeletionQueueTableRetain.StreamArn
- - !GetAtt DeletionQueueTableNotRetain.StreamArn
- DataMapperTable:
- Value: !If
- - ShouldRetainTables
- - !Ref DataMapperTableRetain
- - !Ref DataMapperTableNotRetain
- JobTable:
- Value: !If
- - ShouldRetainTables
- - !Ref JobTableRetain
- - !Ref JobTableNotRetain
- JobTableDateGSI:
- Value: Date-GSI
- JobTableStreamArn:
- Value: !If
- - ShouldRetainTables
- - !GetAtt JobTableRetain.StreamArn
- - !GetAtt JobTableNotRetain.StreamArn
|