Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup CFN for Linkry Domain names #37

Merged
merged 2 commits into from
Jan 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 57 additions & 9 deletions cloudformation/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Parameters:

Conditions:
IsProd: !Equals [!Ref RunEnvironment, 'prod']
IsDev: !Equals [!Ref RunEnvironment, 'dev']
ShouldAttachVpc:
!Equals [true, !Ref VpcRequired]

Expand All @@ -39,10 +40,14 @@ Mappings:
ApiCertificateArn: arn:aws:acm:us-east-1:427040638965:certificate/63ccdf0b-d2b5-44f0-b589-eceffb935c23
HostedZoneId: Z04502822NVIA85WM2SML
ApiDomainName: "aws.qa.acmuiuc.org"
LinkryApiDomainName: "aws.qa.acmuiuc.org"
LinkryApiCertificateArn: arn:aws:acm:us-east-1:427040638965:certificate/63ccdf0b-d2b5-44f0-b589-eceffb935c23
prod:
ApiCertificateArn: arn:aws:acm:us-east-1:298118738376:certificate/6142a0e2-d62f-478e-bf15-5bdb616fe705
HostedZoneId: Z05246633460N5MEB9DBF
ApiDomainName: "aws.acmuiuc.org" # CHANGE ME
ApiDomainName: "aws.acmuiuc.org"
LinkryApiDomainName: "acm.illinois.edu"
LinkryApiCertificateArn: arn:aws:acm:us-east-1:298118738376:certificate/a902d70d-1991-400e-8be9-65befa8fa324
EnvironmentToCidr:
dev:
SecurityGroupIds:
Expand Down Expand Up @@ -93,7 +98,7 @@ Resources:
Environment:
Variables:
RunEnvironment: !Ref RunEnvironment
VpcConfig:
VpcConfig:
Ipv6AllowedForDualStack: !If [ShouldAttachVpc, True, !Ref AWS::NoValue]
SecurityGroupIds: !If [ShouldAttachVpc, !FindInMap [EnvironmentToCidr, !Ref RunEnvironment, SecurityGroupIds], !Ref AWS::NoValue]
SubnetIds: !If [ShouldAttachVpc, !FindInMap [EnvironmentToCidr, !Ref RunEnvironment, SubnetIds], !Ref AWS::NoValue]
Expand All @@ -107,7 +112,7 @@ Resources:

IamGroupRolesTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: "Retain"
DeletionPolicy: "Retain"
Properties:
BillingMode: 'PAY_PER_REQUEST'
TableName: infra-core-api-iam-grouproles
Expand All @@ -123,7 +128,7 @@ Resources:

IamUserRolesTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: "Retain"
DeletionPolicy: "Retain"
Properties:
BillingMode: 'PAY_PER_REQUEST'
TableName: infra-core-api-iam-userroles
Expand All @@ -139,7 +144,7 @@ Resources:

EventRecordsTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: "Retain"
DeletionPolicy: "Retain"
Properties:
BillingMode: 'PAY_PER_REQUEST'
TableName: infra-core-api-events
Expand All @@ -164,7 +169,7 @@ Resources:

CacheRecordsTable:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: "Retain"
DeletionPolicy: "Retain"
Properties:
BillingMode: 'PAY_PER_REQUEST'
TableName: infra-core-api-cache
Expand All @@ -183,7 +188,7 @@ Resources:

AppApiGateway:
Type: AWS::Serverless::Api
DependsOn:
DependsOn:
- AppApiLambdaFunction
Properties:
Name: !Sub ${ApplicationPrefix}-gateway
Expand All @@ -194,7 +199,7 @@ Resources:
Name: AWS::Include
Parameters:
Location: ./phony-swagger.yml
Domain:
Domain:
DomainName: !Sub
- "${ApplicationPrefix}.${BaseDomainName}"
- BaseDomainName: !FindInMap
Expand Down Expand Up @@ -296,4 +301,47 @@ Resources:
- !Ref AWS::AccountId
- ":"
- !Ref AppApiGateway
- "/*/*/*"
- "/*/*/*"

LinkryCustomDomainName:
Type: AWS::ApiGateway::DomainName
Properties:
RegionalCertificateArn: !FindInMap [ApiGwConfig, !Ref RunEnvironment, LinkryApiCertificateArn]
EndpointConfiguration:
Types:
- REGIONAL
DomainName: !Sub
- "go.${BaseDomainName}"
- BaseDomainName: !FindInMap
- ApiGwConfig
- !Ref RunEnvironment
- LinkryApiDomainName
SecurityPolicy: TLS_1_2

LinkryRoute53RecordSetDev:
Condition: IsDev
Type: AWS::Route53::RecordSet
Properties:
HostedZoneId: !FindInMap [ApiGwConfig, !Ref RunEnvironment, HostedZoneId]
Name: !Sub
- "go.${BaseDomainName}"
- BaseDomainName: !FindInMap
- ApiGwConfig
- !Ref RunEnvironment
- LinkryApiDomainName
Type: A
AliasTarget:
DNSName: !GetAtt LinkryCustomDomainName.RegionalDomainName
HostedZoneId: !GetAtt LinkryCustomDomainName.RegionalHostedZoneId

LinkryApiMapping:
Type: 'AWS::ApiGatewayV2::ApiMapping'
Properties:
DomainName: !Sub
- "go.${BaseDomainName}"
- BaseDomainName: !FindInMap
- ApiGwConfig
- !Ref RunEnvironment
- LinkryApiDomainName
ApiId: !Ref AppApiGateway
Stage: default
Loading