Difference between revisions of "Data."
Jump to navigation
Jump to search
Line 22: | Line 22: | ||
− | == | + | == Examples == |
resource "[[aws_s3_bucket]]" "example" { | resource "[[aws_s3_bucket]]" "example" { | ||
bucket = "my-tf-test-bucket" | bucket = "my-tf-test-bucket" | ||
Line 30: | Line 30: | ||
bucket = aws_s3_bucket.example.id | bucket = aws_s3_bucket.example.id | ||
[[policy]] = [[data.]]aws_iam_policy_document.allow_access_from_another_account.json | [[policy]] = [[data.]]aws_iam_policy_document.allow_access_from_another_account.json | ||
+ | } | ||
+ | |||
+ | == aws_ami == | ||
+ | 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 | ||
} | } | ||
Revision as of 05:58, 13 March 2023
identity_store_id = tolist(data.aws_ssoadmin_instances.example.identity_store_ids)[0]
data.aws_caller_identity data.aws_availability_zones.available.names
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) }
Examples
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
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 }
See also
- AWS Data sources:
aws_region
,aws_vpc
,aws_caller_identity
,aws_availability_zones
,aws_eip
,aws_flow_log
,template_file, aws_ami
- Terraform functions, Terraform collection functions:
tolist
,toset
,length
,sum
,file
,join
,depends_on
,zipmap
,replace
,lookup
,read files
,concat
,merge, templatefile, for_each, format, element, slice, try, filebase64, upper, filemd5, coalesce, formatlist, flatten
Advertising: