Skip to content

Commit

Permalink
added at rest encryption to DynamoDB and Elasticsearch
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwittig committed May 25, 2018
1 parent 9c2a68e commit f6dffe8
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 7 deletions.
3 changes: 1 addition & 2 deletions docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ DynamoDB table with auto scaling for read and write capacity.

## Limitations
* No backup (see `operations/backup-dynamodb-native.yaml`)
* No encryption at rest
* Encryption at rest with AWS managed CMK (customer managed is not supported)

# ElastiCache memcached

Expand Down Expand Up @@ -95,7 +95,6 @@ Cluster of Elasticsearch nodes.

## Limitations
* No auto scaling
* No encryption at rest

# RDS Aurora

Expand Down
10 changes: 9 additions & 1 deletion state/dynamodb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,20 @@ Parameters:
Description: 'Target read capacity utilization (in percent) that auto scaling tries to achieve (if you have spiky reads, a lower number is better).'
Type: Number
Default: 80
Encryption:
Description: 'Enable server side encryption using KMS (AWS managed) CMK.'
Type: String
Default: false
AllowedValues: [aws, false]
Conditions:
HasAlertTopic: !Not [!Equals [!Ref ParentAlertStack, '']]
HasSortKey: !Not [!Equals [!Ref SortKeyName, '']]
HasTableName: !Not [!Equals [!Ref TableName, '']]
HasAwsManagedEncryption: !Equals [!Ref Encryption, aws]
Resources:
Table:
Type: 'AWS::DynamoDB::Table'
Properties: # TODO add SSESpecification as soon as DynamoDB supports CMK and update docs
Properties:
TableName: !If [HasTableName, !Ref TableName, !Ref 'AWS::NoValue']
AttributeDefinitions: !If
- HasSortKey
Expand All @@ -113,6 +119,8 @@ Resources:
ProvisionedThroughput:
ReadCapacityUnits: !Ref MinReadCapacityUnits
WriteCapacityUnits: !Ref MinWriteCapacityUnits
SSESpecification:
SSEEnabled: !If [HasAwsManagedEncryption, true, false]
RoleScaling:
Type: 'AWS::IAM::Role'
Properties:
Expand Down
43 changes: 42 additions & 1 deletion state/elasticsearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,19 @@ Parameters:
Description: 'Name that is used to create the DNS entry ${SubDomainName}.${HostedZoneName} (required when ParentZoneStack is set, otherwise not considered)'
Type: String
Default: elasticsearch
Encryption:
Description: 'Enable server side encryption using KMS (customer managed) CMK. Only works with certain instance types (https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/aes-supported-instance-types.html)'
Type: String
Default: false
AllowedValues: [true, false]
Conditions:
HasZone: !Not [!Equals [!Ref ParentZoneStack, '']]
HasSSHBastionSecurityGroup: !Not [!Equals [!Ref ParentSSHBastionStack, '']]
HasAlertTopic: !Not [!Equals [!Ref ParentAlertStack, '']]
HasSingleClusterInstance: !Equals [!Ref ClusterInstanceCount, '1']
HasDedicatedMasterNodes: !Not [!Equals [!Ref DedicatedMasterCount, 0]]
HasAlertTopicAndNotSingleClusterInstance: !And [!Condition HasAlertTopic, !Not [!Condition HasSingleClusterInstance]]
HasEncryption: !Equals [!Ref Encryption, true]
Resources:
RecordSet:
Condition: HasZone
Expand Down Expand Up @@ -132,9 +138,43 @@ Resources:
ToPort: 443
SourceSecurityGroupId:
'Fn::ImportValue': !Sub '${ParentSSHBastionStack}-SecurityGroup'
Key:
Condition: HasEncryption
Type: 'AWS::KMS::Key'
Properties:
KeyPolicy:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
AWS: !Sub 'arn:aws:iam::${AWS::AccountId}:root'
Action: 'kms:*'
Resource: '*'
- Effect: Allow
Principal:
AWS: '*'
Action:
- 'kms:Encrypt'
- 'kms:Decrypt'
- 'kms:ReEncrypt*'
- 'kms:GenerateDataKey*'
- 'kms:CreateGrant'
- 'kms:ListGrants'
- 'kms:DescribeKey'
Resource: '*'
Condition:
StringEquals:
'kms:CallerAccount': !Ref 'AWS::AccountId'
'kms:ViaService': !Sub 'es.${AWS::Region}.amazonaws.com'
KeyAlias:
Condition: HasEncryption
Type: 'AWS::KMS::Alias'
Properties:
AliasName: !Sub 'alias/${AWS::StackName}'
TargetKeyId: !Ref Key
ElasticsearchDomain:
Type: 'AWS::Elasticsearch::Domain'
Properties: # TODO add EncryptionAtRestOptions as soon as available in CloudFormation and update docs
Properties:
AccessPolicies:
Version: '2012-10-17'
Statement:
Expand All @@ -157,6 +197,7 @@ Resources:
InstanceType: !Ref ClusterInstanceType
ZoneAwarenessEnabled: !If [HasSingleClusterInstance, false, true]
ElasticsearchVersion: '5.5'
EncryptionAtRestOptions: !If [HasEncryption, {Enabled: true, KmsKeyId: !Ref Key}, !Ref 'AWS::NoValue']
SnapshotOptions:
AutomatedSnapshotStartHour: 10
VPCOptions:
Expand Down
2 changes: 1 addition & 1 deletion state/rds-aurora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Parameters:
Type: String
Default: aurora
Encryption:
Description: 'Enable server side encryption using KMS CMK key.'
Description: Description: 'Enable server side encryption using KMS (customer managed) CMK.'
Type: String
Default: false
AllowedValues: [true, false]
Expand Down
2 changes: 1 addition & 1 deletion state/rds-postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Parameters:
Type: String
Default: postgres
Encryption:
Description: 'Enable server side encryption using KMS CMK key.'
Description: Description: 'Enable server side encryption using KMS (customer managed) CMK.'
Type: String
Default: false
AllowedValues: [true, false]
Expand Down
2 changes: 1 addition & 1 deletion state/s3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Parameters:
Default: 0
MinValue: 0
Encryption:
Description: 'Enable server side encryption using KMS CMK key.'
Description: Description: 'Enable server side encryption using KMS (customer managed) CMK.'
Type: String
Default: false
AllowedValues: [true, false]
Expand Down

0 comments on commit f6dffe8

Please sign in to comment.