How to Deploy an Amazon Redshift Serverless in AWS using Terraform
Amazon Redshift is a data warehouse product released by Amazon Web Services (AWS) back in 2012, and it is one the most popular products of this cloud computing market leader.
Amazon Redshift is a fully managed, petabyte-scale data warehouse service in the cloud, and it is available in two options:
- Amazon Redshift Serverless: we deploy a namespace (a collection of database objects and users) and a workgroup (a collection of compute resources). Amazon Redshift Serverless automatically provisions and manages capacity for us. We can specify base data warehouse capacity to select our workloads’ right price/performance balance. We can also specify maximum RPU hours to set cost controls to ensure that costs are predictable (this story).
- Amazon Redshift Cluster: we deploy a provisioned cluster consisting of compute nodes and a leader node. We build a cluster with node types that meet our cost and performance specifications. If you want to deploy an Amazon Redshift Cluster in AWS using Terraform, check this story.
To deploy Amazon Redshift Serverless, we will need the following:
- AWS Credentials
- Define AWS and Terraform Providers
- Create a VPC and Subnets
- Create a Security Group
- Create an AWS IAM Role and IAM Policy
- Create the AWS Redshift Serverless Namespace
- Create the AWS Redshift Serverless Workgroup
Note: For clarity, we prefer to define separate files. However, you can put together the code using the traditional main.tf, variables.tf, and output.tf layout.
2. AWS Credentials
Before creating our Redshift Serverless, we will need AWS Credentials to execute our Terraform code.
The AWS provider offers a few options for providing credentials for authentication:
- Static credentials
- Environment variables
- Shared credentials/configuration file