Skip to content

Commit f6b8794

Browse files
authored
fix: add DeletionProtection to AWS::Cognito::UserPool (#3041)
1 parent 8447deb commit f6b8794

5 files changed

+278
-0
lines changed

samtranslator/model/cognito.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class CognitoUserPool(Resource):
99
"AdminCreateUserConfig": GeneratedProperty(),
1010
"AliasAttributes": GeneratedProperty(),
1111
"AutoVerifiedAttributes": GeneratedProperty(),
12+
"DeletionProtection": GeneratedProperty(),
1213
"DeviceConfiguration": GeneratedProperty(),
1314
"EmailConfiguration": GeneratedProperty(),
1415
"EmailVerificationMessage": GeneratedProperty(),
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Transform: AWS::Serverless-2016-10-31
2+
Resources:
3+
MyUserPool:
4+
Type: AWS::Cognito::UserPool
5+
Properties:
6+
DeletionProtection: ACTIVE
7+
8+
MyFunction:
9+
Type: AWS::Serverless::Function
10+
Properties:
11+
Runtime: python3.8
12+
InlineCode: foo
13+
Handler: bar
14+
Events:
15+
CognitoEvent:
16+
Type: Cognito
17+
Properties:
18+
Trigger: CustomMessage
19+
UserPool: !Ref MyUserPool
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"Resources": {
3+
"MyFunction": {
4+
"Properties": {
5+
"Code": {
6+
"ZipFile": "foo"
7+
},
8+
"Handler": "bar",
9+
"Role": {
10+
"Fn::GetAtt": [
11+
"MyFunctionRole",
12+
"Arn"
13+
]
14+
},
15+
"Runtime": "python3.8",
16+
"Tags": [
17+
{
18+
"Key": "lambda:createdBy",
19+
"Value": "SAM"
20+
}
21+
]
22+
},
23+
"Type": "AWS::Lambda::Function"
24+
},
25+
"MyFunctionCognitoPermission": {
26+
"Properties": {
27+
"Action": "lambda:InvokeFunction",
28+
"FunctionName": {
29+
"Ref": "MyFunction"
30+
},
31+
"Principal": "cognito-idp.amazonaws.com",
32+
"SourceArn": {
33+
"Fn::GetAtt": [
34+
"MyUserPool",
35+
"Arn"
36+
]
37+
}
38+
},
39+
"Type": "AWS::Lambda::Permission"
40+
},
41+
"MyFunctionRole": {
42+
"Properties": {
43+
"AssumeRolePolicyDocument": {
44+
"Statement": [
45+
{
46+
"Action": [
47+
"sts:AssumeRole"
48+
],
49+
"Effect": "Allow",
50+
"Principal": {
51+
"Service": [
52+
"lambda.amazonaws.com"
53+
]
54+
}
55+
}
56+
],
57+
"Version": "2012-10-17"
58+
},
59+
"ManagedPolicyArns": [
60+
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
61+
],
62+
"Tags": [
63+
{
64+
"Key": "lambda:createdBy",
65+
"Value": "SAM"
66+
}
67+
]
68+
},
69+
"Type": "AWS::IAM::Role"
70+
},
71+
"MyUserPool": {
72+
"Properties": {
73+
"DeletionProtection": "ACTIVE",
74+
"LambdaConfig": {
75+
"CustomMessage": {
76+
"Fn::GetAtt": [
77+
"MyFunction",
78+
"Arn"
79+
]
80+
}
81+
}
82+
},
83+
"Type": "AWS::Cognito::UserPool"
84+
}
85+
}
86+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"Resources": {
3+
"MyFunction": {
4+
"Properties": {
5+
"Code": {
6+
"ZipFile": "foo"
7+
},
8+
"Handler": "bar",
9+
"Role": {
10+
"Fn::GetAtt": [
11+
"MyFunctionRole",
12+
"Arn"
13+
]
14+
},
15+
"Runtime": "python3.8",
16+
"Tags": [
17+
{
18+
"Key": "lambda:createdBy",
19+
"Value": "SAM"
20+
}
21+
]
22+
},
23+
"Type": "AWS::Lambda::Function"
24+
},
25+
"MyFunctionCognitoPermission": {
26+
"Properties": {
27+
"Action": "lambda:InvokeFunction",
28+
"FunctionName": {
29+
"Ref": "MyFunction"
30+
},
31+
"Principal": "cognito-idp.amazonaws.com",
32+
"SourceArn": {
33+
"Fn::GetAtt": [
34+
"MyUserPool",
35+
"Arn"
36+
]
37+
}
38+
},
39+
"Type": "AWS::Lambda::Permission"
40+
},
41+
"MyFunctionRole": {
42+
"Properties": {
43+
"AssumeRolePolicyDocument": {
44+
"Statement": [
45+
{
46+
"Action": [
47+
"sts:AssumeRole"
48+
],
49+
"Effect": "Allow",
50+
"Principal": {
51+
"Service": [
52+
"lambda.amazonaws.com"
53+
]
54+
}
55+
}
56+
],
57+
"Version": "2012-10-17"
58+
},
59+
"ManagedPolicyArns": [
60+
"arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
61+
],
62+
"Tags": [
63+
{
64+
"Key": "lambda:createdBy",
65+
"Value": "SAM"
66+
}
67+
]
68+
},
69+
"Type": "AWS::IAM::Role"
70+
},
71+
"MyUserPool": {
72+
"Properties": {
73+
"DeletionProtection": "ACTIVE",
74+
"LambdaConfig": {
75+
"CustomMessage": {
76+
"Fn::GetAtt": [
77+
"MyFunction",
78+
"Arn"
79+
]
80+
}
81+
}
82+
},
83+
"Type": "AWS::Cognito::UserPool"
84+
}
85+
}
86+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"Resources": {
3+
"MyFunction": {
4+
"Properties": {
5+
"Code": {
6+
"ZipFile": "foo"
7+
},
8+
"Handler": "bar",
9+
"Role": {
10+
"Fn::GetAtt": [
11+
"MyFunctionRole",
12+
"Arn"
13+
]
14+
},
15+
"Runtime": "python3.8",
16+
"Tags": [
17+
{
18+
"Key": "lambda:createdBy",
19+
"Value": "SAM"
20+
}
21+
]
22+
},
23+
"Type": "AWS::Lambda::Function"
24+
},
25+
"MyFunctionCognitoPermission": {
26+
"Properties": {
27+
"Action": "lambda:InvokeFunction",
28+
"FunctionName": {
29+
"Ref": "MyFunction"
30+
},
31+
"Principal": "cognito-idp.amazonaws.com",
32+
"SourceArn": {
33+
"Fn::GetAtt": [
34+
"MyUserPool",
35+
"Arn"
36+
]
37+
}
38+
},
39+
"Type": "AWS::Lambda::Permission"
40+
},
41+
"MyFunctionRole": {
42+
"Properties": {
43+
"AssumeRolePolicyDocument": {
44+
"Statement": [
45+
{
46+
"Action": [
47+
"sts:AssumeRole"
48+
],
49+
"Effect": "Allow",
50+
"Principal": {
51+
"Service": [
52+
"lambda.amazonaws.com"
53+
]
54+
}
55+
}
56+
],
57+
"Version": "2012-10-17"
58+
},
59+
"ManagedPolicyArns": [
60+
"arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
61+
],
62+
"Tags": [
63+
{
64+
"Key": "lambda:createdBy",
65+
"Value": "SAM"
66+
}
67+
]
68+
},
69+
"Type": "AWS::IAM::Role"
70+
},
71+
"MyUserPool": {
72+
"Properties": {
73+
"DeletionProtection": "ACTIVE",
74+
"LambdaConfig": {
75+
"CustomMessage": {
76+
"Fn::GetAtt": [
77+
"MyFunction",
78+
"Arn"
79+
]
80+
}
81+
}
82+
},
83+
"Type": "AWS::Cognito::UserPool"
84+
}
85+
}
86+
}

0 commit comments

Comments
 (0)