how to use template_file as object in aws_s3_bucket_object

4,005 views
Skip to first unread message

Mudasir Mirza

unread,
Dec 13, 2016, 12:23:35 AM12/13/16
to Terraform
I am trying to upload a file to S3 but using a template_file

data "template_file" "ecs_config" {
  template = "${file("${path.cwd}/ecs.config.tpl")}"

  vars {
    ecs_cluster_name = "${var.ecs_cluster_name}"
  }
}

resource "aws_s3_bucket_object" "object" {
  bucket = "${var.ecs_config_bucket_name}"
  key = "ecs.config"
  source = "${data.template_file.ecs_config.rendered}"
}


but it fails with below error

aws_s3_bucket_object.object: Error opening S3 bucket object source (<CONTENT OF FILE>)

I am using Terraform v0.7.13

Just want to know how to use template_file as s3 source.

Teemu Matilainen

unread,
Dec 13, 2016, 3:18:02 AM12/13/16
to terrafo...@googlegroups.com

Hi,

The source argument specifies a local file path. Here you want to use content. See the docs for more info.

Cheers,
- Teemu

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/ff518572-ce7b-43e3-be1e-5571b24b8568%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages