Terraform: Deploying an AWS Service Catalog product

AWS terraform Service Catalog product

2 min read | by Jordi Prats

Provisioning a AWS Service Catalog Product can be done with any IaC tool. Terraform is no different.

To create the code to deploy the product, we just need to create the main.tf file with the following content:

provider "aws" {
  region = "us-west-2"
}

resource "aws_servicecatalog_provisioned_product" "s3-test" {
  name                       = "terraforms3"
  product_name               = "S3Bucket"
  provisioning_artifact_name = "1.2.3"

  provisioning_parameters {
    key   = "BucketName"
    value = "demos3bucket"
  }

  tags = {
    "an" = "example"
  }
}

Just as with the AWS CDK example, we are creating a new instance of the product named S3Bucket with the version 1.2.3. The product requires a parameter named BucketName with the value demos3bucket. We are also adding a tag to the product with the key an and the value example. All of this is done using the aws_servicecatalog_provisioned_product resource.

To deploy it, we just need to use the terraform apply command:

terraform apply

Posted on 05/09/2024

Categories