Skip to content

Commit a6d7b6f

Browse files
committed
Update resource policy
1 parent a7c2f85 commit a6d7b6f

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

backend/src/iac/update-api-policy.js

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,29 +62,36 @@ async function main() {
6262
const policy = {
6363
Version: '2012-10-17',
6464
Statement: [
65-
// Allow authenticated Cognito users
6665
{
67-
Effect: 'Allow',
68-
Principal: '*',
69-
Action: 'execute-api:Invoke',
70-
Resource: `arn:aws:execute-api:${REGION}:*:${api.id}/*/*`,
71-
Condition: {
72-
StringEquals: {
73-
'cognito-identity.amazonaws.com:aud': cognitoUserPoolId
66+
"Version": "2012-10-17",
67+
"Statement": [
68+
// Allow OPTIONS requests
69+
{
70+
"Effect": "Allow",
71+
"Principal": "*",
72+
"Action": "execute-api:Invoke",
73+
"Resource": "arn:aws:execute-api:us-east-1:*:xhvwo6wp66/*/OPTIONS/*"
74+
},
75+
{
76+
// Allow all other requests - authentication will be handled by Cognito
77+
"Effect": "Allow",
78+
"Principal": "*",
79+
"Action": "execute-api:Invoke",
80+
"Resource": "arn:aws:execute-api:us-east-1:*:xhvwo6wp66/*/*"
81+
},
82+
{
83+
// Deny non-HTTPS requests
84+
"Effect": "Deny",
85+
"Principal": "*",
86+
"Action": "execute-api:Invoke",
87+
"Resource": "arn:aws:execute-api:us-east-1:*:xhvwo6wp66/*/*",
88+
"Condition": {
89+
"Bool": {
90+
"aws:SecureTransport": "false"
91+
}
92+
}
7493
}
75-
}
76-
},
77-
// Deny non-HTTPS requests
78-
{
79-
Effect: 'Deny',
80-
Principal: '*',
81-
Action: 'execute-api:Invoke',
82-
Resource: `arn:aws:execute-api:${REGION}:*:${api.id}/*/*`,
83-
Condition: {
84-
Bool: {
85-
'aws:SecureTransport': 'false'
86-
}
87-
}
94+
]
8895
}
8996
]
9097
};

0 commit comments

Comments
 (0)