Created
August 16, 2020 22:36
-
-
Save homoluctus/92939c6c9442ebba51f2fa8094124439 to your computer and use it in GitHub Desktop.
RDS Proxy CloudFormation Template
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
AWSTemplateFormatVersion: "2010-09-09" | |
Parameters: | |
# DB Proxy | |
ProxyName: | |
Type: String | |
ProxyEngineFamily: | |
Type: String | |
AllowedValues: | |
- MYSQL | |
- POSTGRESQL | |
ProxyIdleClientTimeout: | |
Type: Number | |
ProxyRequireTLS: | |
Type: String | |
AllowedValues: | |
- true | |
- false | |
Default: false | |
ProxyVpcSecurityGroupIds: | |
Type: List<AWS::EC2::SecurityGroup::Id> | |
ProxyVpcSubnetIds: | |
Type: List<AWS::EC2::Subnet::Id> | |
# DB Proxy Target Group | |
ProxyTargetConnectionBorrowTimeout: | |
Type: Number | |
ProxyTargetMaxConnectionsPercent: | |
Type: Number | |
ProxyTargetMaxIdleConnectionsPercent: | |
Type: Number | |
ProxyTargetDBClusterIdentifiers: | |
Type: CommaDelimitedList | |
# Secrets Manager | |
SecretsManagerRoleName: | |
Type: String | |
SecretsManagerName: | |
Type: String | |
SecretsManagerKMSKeyId: | |
Type: String | |
SecretsManagerManagedPolicyName: | |
Type: String | |
Resources: | |
RDSProxy: | |
Type: "AWS::RDS::DBProxy" | |
Properties: | |
Auth: | |
- AuthScheme: SECRETS | |
IAMAuth: DISABLED | |
SecretArn: !Sub "arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:${SecretsManagerName}" | |
DBProxyName: !Ref ProxyName | |
EngineFamily: !Ref ProxyEngineFamily | |
IdleClientTimeout: !Ref ProxyIdleClientTimeout | |
RequireTLS: !Ref ProxyRequireTLS | |
RoleArn: !GetAtt SecretsManagerRole.Arn | |
VpcSecurityGroupIds: !Ref ProxyVpcSecurityGroupIds | |
VpcSubnetIds: !Ref ProxyVpcSubnetIds | |
RDSProxyTargetGroup: | |
Type: "AWS::RDS::DBProxyTargetGroup" | |
Properties: | |
ConnectionPoolConfigurationInfo: | |
ConnectionBorrowTimeout: !Ref ProxyTargetConnectionBorrowTimeout | |
MaxConnectionsPercent: !Ref ProxyTargetMaxConnectionsPercent | |
MaxIdleConnectionsPercent: !Ref ProxyTargetMaxIdleConnectionsPercent | |
DBClusterIdentifiers: !Ref ProxyTargetDBClusterIdentifiers | |
DBProxyName: !Ref RDSProxy | |
TargetGroupName: default | |
SecretsManagerRole: | |
Type: "AWS::IAM::Role" | |
Properties: | |
AssumeRolePolicyDocument: | |
Version: "2012-10-17" | |
Statement: | |
- Effect: Allow | |
Principal: | |
Service: | |
- "rds.amazonaws.com" | |
Action: | |
- "sts:AssumeRole" | |
Description: "Use for RDS Proxy" | |
ManagedPolicyArns: | |
- !Ref SecretsManagerManagedPolicy | |
Path: / | |
RoleName: !Ref SecretsManagerRoleName | |
SecretsManagerManagedPolicy: | |
Type: "AWS::IAM::ManagedPolicy" | |
Properties: | |
Description: "Get values from Secrets Manager" | |
ManagedPolicyName: !Ref SecretsManagerManagedPolicyName | |
Path: / | |
PolicyDocument: | |
Version: "2012-10-17" | |
Statement: | |
- Effect: Allow | |
Action: | |
- "secretsmanager:GetSecretValue" | |
Resource: !Sub "arn:aws:secretsmanager:${AWS::Region}:${AWS::AccountId}:secret:${SecretsManagerName}" | |
- Effect: Allow | |
Action: | |
- "kms:Decrypt" | |
Resource: !Sub "arn:aws:kms:${AWS::Region}:${AWS::AccountId}:key/${SecretsManagerKMSKeyId}" | |
Condition: | |
StringEquals: | |
kms:ViaService: !Sub "secretsmanager.${AWS::Region}.amazonaws.com" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi Anand
Try this template: