Difference between revisions of "Terraform data source: data"

From wikieduonline
Jump to navigation Jump to search
Line 26: Line 26:
 
  data "[[aws_vpc]]" "selected" {
 
  data "[[aws_vpc]]" "selected" {
 
   id = var.[[my_vpc_id]]
 
   id = var.[[my_vpc_id]]
 +
}
 +
 +
 +
data "[[template_file]]" "my-secret" {
 +
  template = [[aws_iam_access_key]].my_new_user.encrypted_secret
 
  }
 
  }
  

Revision as of 12:46, 4 March 2022

Available since 2016

TOMERGE: Terraform data sources

Example

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ami

data "aws_ami" "myexample" {
  most_recent = true

  owners = ["self"]
  tags = {
    Name   = "app-server"
    Tested = "true"
  }
}

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc

data "aws_vpc" "selected" {
  id = var.my_vpc_id
}


data "template_file" "my-secret" {
  template = aws_iam_access_key.my_new_user.encrypted_secret
}

Related terms

See also

  • https://www.hashicorp.com/blog/terraform-aws-provider-4-0-refactors-s3-bucket-resource
  • Advertising: