John Pal
John Pal

Reputation: 85

Terraform get json data from S3

I am trying to create a EMR using Terraform. I am able to specify a local file to configurations parameter but I want to know if it's possible to specify a json file in S3 and if so how.

resource "aws_emr_cluster" "cluster" {
  ...
  ...
  ...
  configurations = "${file("local/file/path/to/json/file")}"
  ...
  ...
}

What I want is be able to specify a s3 file path.

Upvotes: 6

Views: 5818

Answers (1)

StephenKing
StephenKing

Reputation: 37580

Use the aws_s3_bucket_object data to retrieve an object's content from S3:

data "aws_s3_bucket_object" "config" {
  bucket = "example-bucket"
  key = "config.json"
}

resource "aws_emr_cluster" "cluster" {
  configurations = "${data.aws_s3_bucket_object.config.body}"
}

Upvotes: 9

Related Questions