Skip to content

Commit 2b1eff7

Browse files
committed
parameterise valid cors
1 parent af6642d commit 2b1eff7

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

cloudformation/lambda.yml

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ Mappings:
4242
dev:
4343
ApiCertificateArn: arn:aws:acm:us-east-1:427040638965:certificate/07a0f957-15ae-4330-be14-25814728b981
4444
ApiDomainName: resume-api-dev.acm.illinois.edu
45+
ValidCorsOrigins:
46+
- "*"
4547
prod:
4648
ApiCertificateArn: arn:aws:acm:us-east-1:298118738376:certificate/4ba7200a-cfc7-4234-b242-0281030df5f5
4749
ApiDomainName: resume-api.acm.illinois.edu
50+
ValidCorsOrigins:
51+
- https://resumes.acm.illinois.edu
4852
EnvironmentToCidr:
4953
dev:
5054
SecurityGroupIds:
@@ -78,6 +82,7 @@ Resources:
7882
Environment:
7983
Variables:
8084
RunEnvironment: !Ref RunEnvironment
85+
ValidCorsOrigins: !Join [",", !FindInMap [ApiGwConfig, !Ref RunEnvironment, ValidCorsOrigins]]
8186
VpcConfig:
8287
Ipv6AllowedForDualStack: True
8388
SecurityGroupIds: !FindInMap [EnvironmentToCidr, !Ref RunEnvironment, SecurityGroupIds]
@@ -368,28 +373,16 @@ Resources:
368373
Properties:
369374
BucketName: !Sub "${ResumeS3BucketName}-${RunEnvironment}"
370375
CorsConfiguration:
371-
!If
372-
- IsProd
373-
- CorsRules:
374-
- AllowedHeaders:
375-
- '*'
376-
AllowedOrigins:
377-
- 'https://resumes.acm.illinois.edu'
378-
AllowedMethods:
379-
- GET
380-
- PUT
381-
Id: CORSAllowProdSite
382-
MaxAge: 3600
383-
- CorsRules:
384-
- AllowedHeaders:
385-
- '*'
386-
AllowedOrigins:
387-
- 'http://localhost:5173'
388-
AllowedMethods:
389-
- GET
390-
- PUT
391-
Id: CORSAllowLocalhost
392-
MaxAge: 3600
376+
- CorsRules:
377+
- AllowedHeaders:
378+
- '*'
379+
AllowedOrigins:
380+
- !FindInMap [ApiGwConfig, !Ref RunEnvironment, ValidCorsOrigins]
381+
AllowedMethods:
382+
- GET
383+
- PUT
384+
Id: CORSAllowProdSite
385+
MaxAge: 3600
393386

394387
Outputs:
395388
ApiUrl:

0 commit comments

Comments
 (0)