I've scoured the Terraform docs for the AWS provider and couldn't find support for CloudFormation::CustomResource in terraform.

I've created my Lambda Functions and now I would like to pass my arguments to my lambda function. The way this is done in CloudFormation is via a custom resource.

I however can't seem to find support for this in Terraform. Am I missing something? Thanks.


The aws_cloudformation_stack resource allows the creation of CloudFormation stacks in Terraform, thus exposing all of CloudFormation's features within a Terraform configuration:

resource "aws_cloudformation_stack" "example" {
  name = "example-custom-resource"

  template_body = <<STACK
  "Resources" : {
    "ExampleCustomResource": {
      "Type" : "Custom::ExampleResource",
      "Properties" : {
        "ServiceToken": "...",
        (other properties specific to the resource)

The Type attribute here can be any string starting with Custom::. The ServiceToken identifies which custom resource provider will handle this custom resource. Any other properties that the custom resource supports can be provided as additional attributes in the Properties object.

Since the format of template_body is just a standard CloudFormation template, the documentation for CustomResource gives the full details on how this feature works.

Terraform does not directly support CloudFormation custom resources as a native Terraform resource, but the aws_cloudformation_stack resource is provided as a way to get the best of both worlds, giving access to CloudFormation-specific features when needed.


You could try the following Provider, it works the same like AWS CloudFormation Custom Resources. You can use it with AWS Lambda or run a script locally in any language


provider "multiverse" {}

resource "multiverse_custom_resource" 
  "spotinst_targetset_and_rules" {
      executor = "python3"
      script = "spotinst_mlb_targetset.py"
      id_key = "id"
      data = <<JSON
    "name": "test-terraform-test",
    "mlb_id": "lb-123",
    "mlb_deployment_id": "dp-123",
    "mlb_listener_ids": ["ls-123", "ls-456"],
    "test_group_callback_fqdn": "test.fqdn.com",
     "control_group_callback_fqdn": "control.fqdn.com"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.