- Newest
- Most votes
- Most comments
There are a few ways that come to mind. Since the RDS database should be in a private subnet and not publicly accessible you will need a way to tunnel to the private connection or run the create table from the private location. The first method would be to spin up a small EC2 host as a bastion that has teh SQL client on it and can connect tot he database instance. Then you could run the create table from it using Terraform.
You could also consider the approach of creating a lambda function using Terraform that can do the create table for you and invoke it from Terraform. There is an example of the invoke here https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/lambda_invocation and as an example even though it is not Postgres if has all the parts you can see and extrapolate to a Postgres example, https://docs.aws.amazon.com/lambda/latest/dg/services-rds-tutorial.html.
To summarize create the Aurora Postgres cluster instance and database, create the lambda function in parallel, have the invoke part have a depends on the database and lambda function creation. I think this will be easier than the EC2 bastion instance route.
Relevant content
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
We are planning to use Lamdba route. Thanks.