Skip to content

Commit d33eb4c

Browse files
committed
Working to get a NAT up and better error checking.
It looks like the issue is more likely a result of the use of the private subnet to deploy the app. We have to use it to connect to the database, but that means that the app cant call out to external services. By setting up the NAT in the infrastructure.yaml we can then connect to other APIs.
1 parent d9dd071 commit d33eb4c

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

.github/workflows/deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ jobs:
7878
exit 1
7979
fi
8080
echo "SUBNET_LIST=subnet-0e66614ca7e9e7247,subnet-013f8ff069404c987" >> $GITHUB_ENV
81+
echo "PUBSUB_LIST=subnet-0f5812eb0691aca6a,subnet-0045ed0716dc4461c" >> $GITHUB_ENV
8182
8283
- name: Deploy CloudFormation stack
8384
run: |
@@ -95,6 +96,7 @@ jobs:
9596
"RDSPassword=${{ secrets.RDS_PASSWORD }}" \
9697
"VPCId=${{ secrets.VPC_ID }}" \
9798
"PrivateSubnets=${{ env.SUBNET_LIST }}" \
99+
"PublicSubnets=${{ env.PUBSUB_LIST }}" \
98100
"DomainName=${{ env.ENDPOINT }}" \
99101
"NativeLandKey=${{ secrets.NATIVELANDKEY }}" \
100102
--capabilities CAPABILITY_NAMED_IAM \

infrastructure/cloudformation-template.yaml

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ Parameters:
3939

4040
PrivateSubnets:
4141
Type: List<AWS::EC2::Subnet::Id>
42-
Description: Private subnets for VPC connector
42+
Description: Private subnets for VPC connector (for the RDS database)
43+
44+
PublicSubnets:
45+
Type: List<AWS::EC2::Subnet::Id>
46+
Description: Public subnets for NAT Gateway (for calls out to external resources)
4347

4448
RDSUsername:
4549
Type: String
@@ -57,6 +61,56 @@ Parameters:
5761
Description: The API key for the Native Lands API
5862

5963
Resources:
64+
65+
# Elastic IP for NAT Gateway
66+
NATGatewayEIP:
67+
Type: AWS::EC2::EIP
68+
Properties:
69+
Domain: vpc
70+
Tags:
71+
- Key: Name
72+
Value: !Sub 'neotoma-nat-eip-${Environment}'
73+
74+
# NAT Gateway in first public subnet
75+
NATGateway:
76+
Type: AWS::EC2::NatGateway
77+
Properties:
78+
AllocationId: !GetAtt NATGatewayEIP.AllocationId
79+
SubnetId: !Select [0, !Ref PublicSubnets]
80+
Tags:
81+
- Key: Name
82+
Value: !Sub 'neotoma-nat-gateway-${Environment}'
83+
# Route table for private subnets
84+
PrivateRouteTable:
85+
Type: AWS::EC2::RouteTable
86+
Properties:
87+
VpcId: !Ref VPCId
88+
Tags:
89+
- Key: Name
90+
Value: !Sub 'neotoma-private-rt-${Environment}'
91+
92+
# Route to NAT Gateway
93+
PrivateRoute:
94+
Type: AWS::EC2::Route
95+
Properties:
96+
RouteTableId: !Ref PrivateRouteTable
97+
DestinationCidrBlock: 0.0.0.0/0
98+
NatGatewayId: !Ref NATGateway
99+
100+
# Associate route table with first private subnet
101+
PrivateSubnetRouteTableAssociation1:
102+
Type: AWS::EC2::SubnetRouteTableAssociation
103+
Properties:
104+
SubnetId: !Select [0, !Ref PrivateSubnets]
105+
RouteTableId: !Ref PrivateRouteTable
106+
107+
# Associate route table with second private subnet
108+
PrivateSubnetRouteTableAssociation2:
109+
Type: AWS::EC2::SubnetRouteTableAssociation
110+
Properties:
111+
SubnetId: !Select [1, !Ref PrivateSubnets]
112+
RouteTableId: !Ref PrivateRouteTable
113+
60114
# Security Group for App Runner
61115
AppRunnerSecurityGroup:
62116
Type: AWS::EC2::SecurityGroup

v2.0/helpers/landing/landing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ const sendNativeLands = async function(req, res, next) {
409409
signal: AbortSignal.timeout(5000),
410410
}).catch((err) => {
411411
console.log('Fetch error caught:', err.name, err.message);
412-
console.log('Full error object:', err); // Add this
412+
console.log('Full error object:', JSON.stringify(err)); // Add this
413413
console.log('Error cause:', err.cause); // Add this - often has the real error!
414414

415415
res.status(500)

0 commit comments

Comments
 (0)