so I got my first AWS bill :smile: Only 20euro but...
# help
j
so I got my first AWS bill 😄 Only 20euro but it was a surprise as I'm just playing around with an idea on SST. I am using a subaccount of my main account so I don't qualify for the free tier. The thing that cost all the money is Amazon Elastic Compute Cloud NatGateway. I'm going to close the subaccount and work on my main account but is there anyway to reduce the NAT Gateway usage/cost?
r
Do you need to run your code inside a VPC? If not, you can ditch the NAT Gateway. Otherwise, take a look at fck-nat
j
Thanks
I think I need a VPC - db with api gateway and lambda
fck-nat looks great, thanks
r
@thdxr knows more about it than me but you may be able to use the data api with your dB and have your lambda outside a VPC
t
Yeah the nat is killer! We have a way to avoid it if you have some flexibility though. The new sst.RDS construct spins up a serverless RDS instance. It creates its own VPC without a nat gateway. Lambdas don't need to be in it because they can talk to it through the data-api (sql over http secured by IAM) We recommend kysely as a slick typescript client for it along with our kysely-data-api library
j
Thanks guys, is there an example anywhere that I can have a look at on how to set this up?
f
@John if you just did this, SST creates a new VPC without NAT
Copy code
new RDS(this, "Database", {
  engine: "postgresql10.14",
  defaultDatabaseName: "my_database",
});
When SST creates the VPC for RDS, it only creates
Public
and
Isolated
subnets. You can read more about the subnet types here https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2-readme.html#subnet-types
j
Thank you