Can we create a Table in Aurora during the infra setup using terraform IaaC code ?
We use terraform for creating the infra in AWS. We want to create RDS Aurora Postgres instance. Terraform has support to create it. But I am stuck at table creation. There is a line of thought that the Table creation is not part of infra, but for me it looks like part of infra (dynamo db tables are created in terraform). We used terraform local exec command as explained in this link . But the concern is that RDS instances are kept in private subnet, not able to connect directly. Doing SSH tunnelling to execute the table creation script has security issues. Would like to understand from the community how does it is handled ? what are the guidance on this issue ? or or Any leads and help on this will be super helpful.
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.
We are planning to use Lamdba route. Thanks.
Duplicate an existing serverless app infra(built in the console management) using terraformerasked 2 months ago
AWS Connect instance creation via Terraform scriptAccepted Answerasked 3 months ago
"Create Aurora Read Replica" option not available to migrate from RDS Postgres 11.12 to Aurora 11.12.asked 2 months ago
Is index creating a blocking operation in Mysql Aurora 5.6asked 9 months ago
Aurora Postgres - Logical Replication with different databases in same instanceasked 4 months ago
create simple RDS Aurora instanceasked 3 months ago
How to create SSL dblink connection from RDS to postgres on premise?asked 4 months ago
Amazon Connect security profile creation via Terraform scriptsAccepted Answerasked 2 months ago
Can we create a Table in Aurora during the infra setup using terraform IaaC code ?Accepted Answerasked a month ago
Can we add column to an existing table in AWS Athena using SQL query?Accepted Answerasked 3 years ago