forked from widdix/aws-cf-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[New Template] security/kms-key - KMS customer managed CMK for AWS services [New Template] state/rds-aurora-serverless - RDS Aurora Serverless [Improvement] state/rds-aurora - MySQL 5.7 and Postgres support [Improvement] state/rds-aurora - PreferredBackupWindow and PreferredMaintenanceWindow are now configurable [Improvement] state/rds-mysql - PreferredBackupWindow and PreferredMaintenanceWindow are now configurable [Improvement] state/rds-postgres - PreferredBackupWindow and PreferredMaintenanceWindow are now configurable
- Loading branch information
1 parent
e106f42
commit 8daf899
Showing
10 changed files
with
655 additions
and
25 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
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
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,137 @@ | ||
--- | ||
# Copyright 2018 widdix GmbH | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Description: 'Security: KMS customer managed CMK for AWS services, a cloudonaut.io template' | ||
Metadata: | ||
'AWS::CloudFormation::Interface': | ||
ParameterGroups: | ||
- Label: | ||
default: 'Parent Stacks' | ||
Parameters: | ||
- ParentAlertStack | ||
- Label: | ||
default: 'KMS Parameters' | ||
Parameters: | ||
- Service | ||
Parameters: | ||
ParentAlertStack: | ||
Description: 'Optional but recommended stack name of parent alert stack based on operations/alert.yaml template.' | ||
Type: String | ||
Default: '' | ||
Service: | ||
Description: 'Which AWS service is allowed to use this CMK?' | ||
Type: String | ||
AllowedValues: | ||
- 'ALL_SERVICES' | ||
- connect | ||
- dms | ||
- ssm | ||
- ec2 | ||
- elasticfilesystem | ||
- es | ||
- kinesis | ||
- kinesisvideo | ||
- lambda | ||
- lex | ||
- redshift | ||
- rds | ||
- secretsmanager | ||
- ses | ||
- s3 | ||
- importexport | ||
- sqs | ||
- workmail | ||
- workspaces | ||
Default: ALL_SERVICES | ||
Conditions: | ||
HasAlertTopic: !Not [!Equals [!Ref ParentAlertStack, '']] | ||
HasServiceAllServices: !Equals [!Ref Service, 'ALL_SERVICES'] | ||
Resources: | ||
Key: | ||
DeletionPolicy: Retain | ||
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: !If | ||
- HasServiceAllServices | ||
- 'kms:CallerAccount': !Ref 'AWS::AccountId' | ||
- 'kms:CallerAccount': !Ref 'AWS::AccountId' | ||
'kms:ViaService': !Sub '${Service}.${AWS::Region}.amazonaws.com' | ||
KeyAlias: | ||
Type: 'AWS::KMS::Alias' | ||
Properties: | ||
AliasName: !Sub 'alias/${AWS::StackName}' | ||
TargetKeyId: !Ref Key | ||
DeletionNotification: | ||
Condition: HasAlertTopic | ||
Type: 'AWS::Events::Rule' | ||
Properties: | ||
EventPattern: | ||
source: | ||
- 'aws.kms' | ||
'detail-type': | ||
- 'AWS API Call via CloudTrail' | ||
resources: | ||
- !GetAtt Key.Arn | ||
detail: | ||
eventSource: | ||
- 'kms.amazonaws.com' | ||
'eventName': | ||
- ScheduleKeyDeletion | ||
- DisableKey | ||
State: ENABLED | ||
Targets: | ||
- Arn: {'Fn::ImportValue': !Sub '${ParentAlertStack}-TopicARN'} | ||
Id: rule | ||
Outputs: | ||
TemplateID: | ||
Description: 'cloudonaut.io template id.' | ||
Value: 'security/kms-key' | ||
TemplateVersion: | ||
Description: 'cloudonaut.io template version.' | ||
Value: '__VERSION__' | ||
StackName: | ||
Description: 'Stack name.' | ||
Value: !Sub '${AWS::StackName}' | ||
KeyId: | ||
Description: 'Key id.' | ||
Value: !Ref Key | ||
Export: | ||
Name: !Sub '${AWS::StackName}-KeyId' | ||
KeyArn: | ||
Description: 'Key ARN.' | ||
Value: !GetAtt 'Key.Arn' | ||
Export: | ||
Name: !Sub '${AWS::StackName}-KeyArn' |
Oops, something went wrong.