Difference between revisions of "Data."

From wikieduonline
Jump to navigation Jump to search
 
(15 intermediate revisions by 3 users not shown)
Line 8: Line 8:
 
* <code>[[data.]]</code>
 
* <code>[[data.]]</code>
  
[[identity_store_id]] = [[tolist]](data.aws_ssoadmin_instances.example.identity_store_ids)[0]
+
* <code>[[identity_store_id]] = [[tolist]](data.aws_ssoadmin_instances.example.identity_store_ids)[0]</code>
  
 +
== data examples ==
  
 +
[[AWS]]:
 
  [[data.aws_caller_identity]]
 
  [[data.aws_caller_identity]]
 +
[[data.aws_region.current.name]]
 
  [[data.aws_availability_zones.available.names]]
 
  [[data.aws_availability_zones.available.names]]
 +
[[data.aws_subnets]]
 +
[[data.aws_ami]].your_ubuntu.id
 +
[[data.aws_iam_policy_document]]
  
 +
[[data.tfe_outputs]]
  
 +
 
  [[provider "kubernetes"]] {
 
  [[provider "kubernetes"]] {
 
   host                  = data.aws_eks_cluster.cluster.endpoint
 
   host                  = data.aws_eks_cluster.cluster.endpoint
Line 21: Line 29:
 
  }
 
  }
  
 +
 +
 +
r53_zone_name = data.terraform_remote_state.r53.outputs.r53_zone_name
 +
r53_zone_id  = data.terraform_remote_state.r53.outputs.r53_zone_id
  
 
== Examples ==
 
== Examples ==
Line 33: Line 45:
  
 
== aws_ami ==
 
== aws_ami ==
  data "aws_ami" "ubuntu" {
+
  data "[[aws_ami]]" "ubuntu" {
 
   most_recent = true
 
   most_recent = true
 
   
 
   
Line 48: Line 60:
 
   owners = ["099720109477"] # Canonical
 
   owners = ["099720109477"] # Canonical
 
  }
 
  }
 +
 +
 +
== Errors ==
 +
* [[Error: Error in function call]]
 +
 +
== Related ==
 +
* <code>[[each.]]</code>
 +
* [[Terraform data block]]
  
 
== See also ==
 
== See also ==
 +
* {{var.}}
 
* {{terraform aws data sources}}
 
* {{terraform aws data sources}}
 
* {{tf functions}}
 
* {{tf functions}}
  
 
[[Category:Terraform]]
 
[[Category:Terraform]]

Latest revision as of 08:30, 24 October 2024

Terraform Data source


data examples[edit]

AWS:

data.aws_caller_identity
data.aws_region.current.name
data.aws_availability_zones.available.names
data.aws_subnets
data.aws_ami.your_ubuntu.id
data.aws_iam_policy_document
data.tfe_outputs


provider "kubernetes" {
 host                   = data.aws_eks_cluster.cluster.endpoint
 token                  = data.aws_eks_cluster_auth.cluster.token
 cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
}


r53_zone_name = data.terraform_remote_state.r53.outputs.r53_zone_name
r53_zone_id   = data.terraform_remote_state.r53.outputs.r53_zone_id

Examples[edit]

resource "aws_s3_bucket" "example" {
  bucket = "my-tf-test-bucket"
}

resource "aws_s3_bucket_policy" "allow_access_from_another_account" {
  bucket = aws_s3_bucket.example.id
  policy = data.aws_iam_policy_document.allow_access_from_another_account.json
}

aws_ami[edit]

data "aws_ami" "ubuntu" {
 most_recent = true

 filter {
   name   = "name"
   values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
 }

 filter {
   name   = "virtualization-type"
   values = ["hvm"]
 }

 owners = ["099720109477"] # Canonical
}


Errors[edit]

Related[edit]

See also[edit]

Advertising: