-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path01-secret-rotation.yml
41 lines (37 loc) · 1.18 KB
/
01-secret-rotation.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Transform: "AWS::Serverless-2016-10-31"
Parameters:
AppName:
Type: String
ApplicationSG:
Type: AWS::EC2::SecurityGroup::Id
Subnets:
Type: List<AWS::EC2::Subnet::Id>
Secret:
Type: String
Resources:
Function:
Type: AWS::Serverless::Application
Properties:
Location:
ApplicationId: arn:aws:serverlessrepo:us-east-1:297356227824:applications/SecretsManagerRDSMySQLRotationSingleUser
SemanticVersion: 1.0.64
Parameters:
endpoint: !Sub 'https://secretsmanager.${AWS::Region}.amazonaws.com'
functionName: !Sub ${AppName}SecretRotation
vpcSecurityGroupIds: !Ref ApplicationSG
vpcSubnetIds: !Join [',', !Ref Subnets]
FunctionPermissions:
Type: AWS::Lambda::Permission
Properties:
Action: 'lambda:InvokeFunction'
FunctionName: !GetAtt Function.Outputs.RotationLambdaARN
Principal: 'secretsmanager.amazonaws.com'
RotationSchedule:
DependsOn:
- FunctionPermissions
Type: "AWS::SecretsManager::RotationSchedule"
Properties:
SecretId: !Ref Secret
RotationLambdaARN: !GetAtt Function.Outputs.RotationLambdaARN
RotationRules:
AutomaticallyAfterDays: 7