docs: Update AWS Data Source docs to have HCL formatted examples (#13467)

* docs: update AWS examples. Disntinguish between alb and alb listener datasource

* more hcl highlighting

* more hcl

* fix missing end quote in docs

* docs: finish updates to AWS data source highlights

Also updates layout to distinguish some resources
This commit is contained in:
Clint 2017-04-07 10:54:28 -05:00 committed by GitHub
parent 1289082c28
commit a3ae38d1bb
43 changed files with 57 additions and 57 deletions

View File

@ -16,7 +16,7 @@ them by domain without having to hard code the ARNs as input.
## Example Usage ## Example Usage
``` ```hcl
data "aws_acm_certificate" "example" { data "aws_acm_certificate" "example" {
domain = "tf.example.com" domain = "tf.example.com"
statuses = ["ISSUED"] statuses = ["ISSUED"]

View File

@ -1,7 +1,7 @@
--- ---
layout: "aws" layout: "aws"
page_title: "AWS: aws_alb" page_title: "AWS: aws_alb"
sidebar_current: "docs-aws-datasource-alb" sidebar_current: "docs-aws-datasource-alb-x"
description: |- description: |-
Provides an Application Load Balancer data source. Provides an Application Load Balancer data source.
--- ---
@ -16,7 +16,7 @@ with it, etc.
## Example Usage ## Example Usage
``` ```hcl
variable "alb_arn" { variable "alb_arn" {
type = "string" type = "string"
default = "" default = ""

View File

@ -16,7 +16,7 @@ information specific to the listener in question.
## Example Usage ## Example Usage
``` ```hcl
variable "listener_arn" { variable "listener_arn" {
type = "string" type = "string"
} }

View File

@ -13,7 +13,7 @@ resources.
## Example Usage ## Example Usage
``` ```hcl
data "aws_ami" "nat_ami" { data "aws_ami" "nat_ami" {
most_recent = true most_recent = true
executable_users = ["self"] executable_users = ["self"]

View File

@ -13,7 +13,7 @@ ASGs within a specific region. This will allow you to pass a list of AutoScaling
## Example Usage ## Example Usage
``` ```hcl
data "aws_autoscaling_groups" "groups" {} data "aws_autoscaling_groups" "groups" {}
resource "aws_autoscaling_notification" "slack_notifications" { resource "aws_autoscaling_notification" "slack_notifications" {

View File

@ -25,7 +25,7 @@ which provides a list of the available zones.
The following example shows how this data source might be used to derive The following example shows how this data source might be used to derive
VPC and subnet CIDR prefixes systematically for an availability zone. VPC and subnet CIDR prefixes systematically for an availability zone.
``` ```hcl
variable "region_number" { variable "region_number" {
# Arbitrary mapping of region name to number to use in # Arbitrary mapping of region name to number to use in
# a VPC's CIDR prefix. # a VPC's CIDR prefix.

View File

@ -17,7 +17,7 @@ which provides some details about a specific availability zone.
## Example Usage ## Example Usage
``` ```hcl
# Declare the data source # Declare the data source
data "aws_availability_zones" "available" {} data "aws_availability_zones" "available" {}

View File

@ -14,7 +14,7 @@ which Terraform is authorized.
## Example Usage ## Example Usage
``` ```hcl
data "aws_caller_identity" "current" {} data "aws_caller_identity" "current" {}
output "account_id" { output "account_id" {

View File

@ -1,7 +1,7 @@
--- ---
layout: "aws" layout: "aws"
page_title: "AWS: aws_canonical_user_id" page_title: "AWS: aws_canonical_user_id"
sidebar_current: "docs-aws-canonical-user-id" sidebar_current: "docs-aws-datasource-canonical-user-id"
description: |- description: |-
Provides the canonical user ID for the AWS account associated with the provider Provides the canonical user ID for the AWS account associated with the provider
connection to AWS. connection to AWS.
@ -14,7 +14,7 @@ for the effective account in which Terraform is working.
## Example Usage ## Example Usage
``` ```hcl
data "aws_canonical_user_id" "current" {} data "aws_canonical_user_id" "current" {}
output "canonical_user_id" { output "canonical_user_id" {

View File

@ -13,7 +13,7 @@ outputs and other useful data including the template body.
## Example Usage ## Example Usage
``` ```hcl
data "aws_cloudformation_stack" "network" { data "aws_cloudformation_stack" "network" {
name = "my-network-stack" name = "my-network-stack"
} }

View File

@ -12,7 +12,7 @@ Use this data source to get information about an RDS instance
## Example Usage ## Example Usage
``` ```hcl
data "aws_db_instance" "database" { data "aws_db_instance" "database" {
db_instance_identifier = "my-test-database" db_instance_identifier = "my-test-database"
} }

View File

@ -12,7 +12,7 @@ Use this data source to get information about an EBS Snapshot for use when provi
## Example Usage ## Example Usage
``` ```hcl
data "aws_ebs_snapshot" "ebs_volume" { data "aws_ebs_snapshot" "ebs_volume" {
most_recent = true most_recent = true
owners = ["self"] owners = ["self"]

View File

@ -13,7 +13,7 @@ resources.
## Example Usage ## Example Usage
``` ```hcl
data "aws_ebs_volume" "ebs_volume" { data "aws_ebs_volume" "ebs_volume" {
most_recent = true most_recent = true

View File

@ -13,7 +13,7 @@ cluster within an AWS ECS service.
## Example Usage ## Example Usage
``` ```hcl
data "aws_ecs_cluster" "ecs-mongo" { data "aws_ecs_cluster" "ecs-mongo" {
cluster_name = "ecs-mongo-production" cluster_name = "ecs-mongo-production"
} }

View File

@ -13,7 +13,7 @@ a specific container within an AWS ECS service.
## Example Usage ## Example Usage
``` ```hcl
data "aws_ecs_container_definition" "ecs-mongo" { data "aws_ecs_container_definition" "ecs-mongo" {
task_definition = "${aws_ecs_task_definition.mongo.id}" task_definition = "${aws_ecs_task_definition.mongo.id}"
container_name = "mongodb" container_name = "mongodb"

View File

@ -14,7 +14,7 @@ a specific AWS ECS task definition.
## Example Usage ## Example Usage
``` ```hcl
# Simply specify the family to find the latest ACTIVE revision in that family. # Simply specify the family to find the latest ACTIVE revision in that family.
data "aws_ecs_task_definition" "mongo" { data "aws_ecs_task_definition" "mongo" {
task_definition = "${aws_ecs_task_definition.mongo.family}" task_definition = "${aws_ecs_task_definition.mongo.family}"

View File

@ -13,7 +13,7 @@ in a given region for the purpose of using in an AWS Route53 Alias.
## Example Usage ## Example Usage
``` ```hcl
data "aws_elb_hosted_zone_id" "main" {} data "aws_elb_hosted_zone_id" "main" {}
resource "aws_route53_record" "www" { resource "aws_route53_record" "www" {

View File

@ -13,7 +13,7 @@ in a given region for the purpose of whitelisting in S3 bucket policy.
## Example Usage ## Example Usage
``` ```hcl
data "aws_elb_service_account" "main" {} data "aws_elb_service_account" "main" {}
resource "aws_s3_bucket" "elb_logs" { resource "aws_s3_bucket" "elb_logs" {

View File

@ -14,7 +14,7 @@ for the effective account in which Terraform is working.
## Example Usage ## Example Usage
``` ```hcl
data "aws_iam_account_alias" "current" {} data "aws_iam_account_alias" "current" {}
output "account_id" { output "account_id" {

View File

@ -14,7 +14,7 @@ This is a data source which can be used to construct a JSON representation of
an IAM policy document, for use with resources which expect policy documents, an IAM policy document, for use with resources which expect policy documents,
such as the `aws_iam_policy` resource. such as the `aws_iam_policy` resource.
``` ```hcl
data "aws_iam_policy_document" "example" { data "aws_iam_policy_document" "example" {
statement { statement {
sid = "1" sid = "1"
@ -149,7 +149,7 @@ The following attribute is exported:
Showing how you can use this as an assume role policy as well as showing how you can specify multiple principal blocks with different types. Showing how you can use this as an assume role policy as well as showing how you can specify multiple principal blocks with different types.
``` ```hcl
data "aws_iam_policy_document" "event_stream_bucket_role_assume_role_policy" { data "aws_iam_policy_document" "event_stream_bucket_role_assume_role_policy" {
statement { statement {
actions = ["sts:AssumeRole"] actions = ["sts:AssumeRole"]

View File

@ -1,6 +1,6 @@
--- ---
layout: "aws" layout: "aws"
page_title: "AWS: aws_iam_role page_title: "AWS: aws_iam_role"
sidebar_current: "docs-aws-datasource-iam-role" sidebar_current: "docs-aws-datasource-iam-role"
description: |- description: |-
Get information on a Amazon IAM role Get information on a Amazon IAM role
@ -14,7 +14,7 @@ properties without having to hard code ARNs as input.
## Example Usage ## Example Usage
``` ```hcl
data "aws_iam_role" "example" { data "aws_iam_role" "example" {
role_name = "an_example_role_name" role_name = "an_example_role_name"
} }

View File

@ -12,7 +12,7 @@ Use this data source to lookup information about IAM Server Certificates.
## Example Usage ## Example Usage
``` ```hcl
data "aws_iam_server_certificate" "my-domain" { data "aws_iam_server_certificate" "my-domain" {
name_prefix = "my-domain.org" name_prefix = "my-domain.org"
latest = true latest = true

View File

@ -13,7 +13,7 @@ resources.
## Example Usage ## Example Usage
``` ```hcl
data "aws_instance" "foo" { data "aws_instance" "foo" {
instance_id = "i-instanceid" instance_id = "i-instanceid"

View File

@ -12,7 +12,7 @@ Use this data source to get the [IP ranges][1] of various AWS products and servi
## Example Usage ## Example Usage
``` ```hcl
data "aws_ip_ranges" "european_ec2" { data "aws_ip_ranges" "european_ec2" {
regions = ["eu-west-1", "eu-central-1"] regions = ["eu-west-1", "eu-central-1"]
services = ["ec2"] services = ["ec2"]

View File

@ -36,7 +36,7 @@ AQECAHgaPa0J8WadplGCqqVAr4HNvDaFSQ+NaiwIBhmm6qDSFwAAAGIwYAYJKoZIhvcNAQcGoFMwUQIB
Now, take that output and add it to your resource definitions. Now, take that output and add it to your resource definitions.
``` ```hcl
data "aws_kms_secret" "db" { data "aws_kms_secret" "db" {
secret { secret {
name = "master_password" name = "master_password"

View File

@ -12,7 +12,7 @@ Use this data source to lookup current AWS partition in which Terraform is worki
## Example Usage ## Example Usage
``` ```hcl
data "aws_partition" "current" {} data "aws_partition" "current" {}
data "aws_iam_policy_document" "s3_policy" { data "aws_iam_policy_document" "s3_policy" {

View File

@ -18,7 +18,7 @@ rules.
## Example Usage ## Example Usage
``` ```hcl
resource "aws_vpc_endpoint" "private_s3" { resource "aws_vpc_endpoint" "private_s3" {
vpc_id = "${aws_vpc.foo.id}" vpc_id = "${aws_vpc.foo.id}"
service_name = "com.amazonaws.us-west-2.s3" service_name = "com.amazonaws.us-west-2.s3"

View File

@ -13,7 +13,7 @@ in a given region for the purpose of allowing Redshift to store audit data in S3
## Example Usage ## Example Usage
``` ```hcl
data "aws_redshift_service_account" "main" {} data "aws_redshift_service_account" "main" {}
resource "aws_s3_bucket" "bucket" { resource "aws_s3_bucket" "bucket" {

View File

@ -20,7 +20,7 @@ which is inheriting an AWS provider configuration from its parent module.
The following example shows how the resource might be used to obtain The following example shows how the resource might be used to obtain
the name of the AWS region configured on the provider. the name of the AWS region configured on the provider.
``` ```hcl
data "aws_region" "current" { data "aws_region" "current" {
current = true current = true
} }

View File

@ -17,7 +17,7 @@ This data source allows to find a Hosted Zone ID given Hosted Zone name and cert
The following example shows how to get a Hosted Zone from it's name and from this data how to create a Record Set. The following example shows how to get a Hosted Zone from it's name and from this data how to create a Record Set.
``` ```hcl
data "aws_route53_zone" "selected" { data "aws_route53_zone" "selected" {
name = "test.com." name = "test.com."
private_zone = true private_zone = true

View File

@ -19,7 +19,7 @@ the Route Table.
The following example shows how one might accept a Route Table id as a variable The following example shows how one might accept a Route Table id as a variable
and use this data source to obtain the data necessary to create a route. and use this data source to obtain the data necessary to create a route.
``` ```hcl
variable "subnet_id" {} variable "subnet_id" {}
data "aws_route_table" "selected" { data "aws_route_table" "selected" {

View File

@ -15,7 +15,7 @@ _optionally_ (see below) content of an object stored inside S3 bucket.
## Example Usage ## Example Usage
``` ```hcl
data "aws_s3_bucket_object" "lambda" { data "aws_s3_bucket_object" "lambda" {
bucket = "my-lambda-functions" bucket = "my-lambda-functions"
key = "hello-world.zip" key = "hello-world.zip"

View File

@ -19,7 +19,7 @@ VPC that the security group belongs to.
The following example shows how one might accept a Security Group id as a variable The following example shows how one might accept a Security Group id as a variable
and use this data source to obtain the data necessary to create a subnet. and use this data source to obtain the data necessary to create a subnet.
``` ```hcl
variable "security_group_id" {} variable "security_group_id" {}
data "aws_security_group" "selected" { data "aws_security_group" "selected" {

View File

@ -14,7 +14,7 @@ without having to hard code the ARNs as input.
## Example Usage ## Example Usage
``` ```hcl
data "aws_sns_topic" "example" { data "aws_sns_topic" "example" {
name = "an_example_topic" name = "an_example_topic"
} }

View File

@ -1,7 +1,7 @@
--- ---
layout: "aws" layout: "aws"
page_title: "AWS: aws_subnet" page_title: "AWS: aws_subnet"
sidebar_current: "docs-aws-datasource-subnet" sidebar_current: "docs-aws-datasource-subnet-x"
description: |- description: |-
Provides details about a specific VPC subnet Provides details about a specific VPC subnet
--- ---
@ -20,7 +20,7 @@ The following example shows how one might accept a subnet id as a variable
and use this data source to obtain the data necessary to create a security and use this data source to obtain the data necessary to create a security
group that allows connections from hosts in that subnet. group that allows connections from hosts in that subnet.
``` ```hcl
variable "subnet_id" {} variable "subnet_id" {}
data "aws_subnet" "selected" { data "aws_subnet" "selected" {

View File

@ -16,7 +16,7 @@ This resource can be useful for getting back a list of subnet ids for a vpc.
The following shows outputing all cidr blocks for every subnet id in a vpc. The following shows outputing all cidr blocks for every subnet id in a vpc.
``` ```hcl
data "aws_subnet_ids" "example" { data "aws_subnet_ids" "example" {
vpc_id = "${var.vpc_id}" vpc_id = "${var.vpc_id}"
} }

View File

@ -1,7 +1,7 @@
--- ---
layout: "aws" layout: "aws"
page_title: "AWS: aws_vpc" page_title: "AWS: aws_vpc"
sidebar_current: "docs-aws-datasource-vpc" sidebar_current: "docs-aws-datasource-vpc-x"
description: |- description: |-
Provides details about a specific VPC Provides details about a specific VPC
--- ---
@ -20,7 +20,7 @@ The following example shows how one might accept a VPC id as a variable
and use this data source to obtain the data necessary to create a subnet and use this data source to obtain the data necessary to create a subnet
within it. within it.
``` ```hcl
variable "vpc_id" {} variable "vpc_id" {}
data "aws_vpc" "selected" { data "aws_vpc" "selected" {

View File

@ -1,7 +1,7 @@
--- ---
layout: "aws" layout: "aws"
page_title: "AWS: aws_vpc_endpoint" page_title: "AWS: aws_vpc_endpoint"
sidebar_current: "docs-aws-datasource-vpc-endpoint" sidebar_current: "docs-aws-datasource-vpc-endpoint-x"
description: |- description: |-
Provides details about a specific VPC endpoint. Provides details about a specific VPC endpoint.
--- ---
@ -13,7 +13,7 @@ a specific VPC endpoint.
## Example Usage ## Example Usage
``` ```hcl
# Declare the data source # Declare the data source
data "aws_vpc_endpoint" "s3" { data "aws_vpc_endpoint" "s3" {
vpc_id = "${aws_vpc.foo.id}" vpc_id = "${aws_vpc.foo.id}"

View File

@ -14,7 +14,7 @@ configured in the provider.
## Example Usage ## Example Usage
``` ```hcl
# Declare the data source # Declare the data source
data "aws_vpc_endpoint_service" "s3" { data "aws_vpc_endpoint_service" "s3" {
service = "s3" service = "s3"

View File

@ -13,7 +13,7 @@ a specific VPC peering connection.
## Example Usage ## Example Usage
``` ```hcl
# Declare the data source # Declare the data source
data "aws_vpc_peering_connection" "pc" { data "aws_vpc_peering_connection" "pc" {
vpc_id = "${aws_vpc.foo.id}" vpc_id = "${aws_vpc.foo.id}"

View File

@ -13,7 +13,7 @@ a specific VPN gateway.
## Example Usage ## Example Usage
``` ```hcl
data "aws_vpn_gateway" "selected" { data "aws_vpn_gateway" "selected" {
filter { filter {
name = "tag:Name" name = "tag:Name"

View File

@ -16,7 +16,7 @@ Use the navigation to the left to read about the available resources.
## Example Usage ## Example Usage
``` ```hcl
# Configure the AWS Provider # Configure the AWS Provider
provider "aws" { provider "aws" {
access_key = "${var.aws_access_key}" access_key = "${var.aws_access_key}"
@ -64,13 +64,13 @@ Access Key and AWS Secret Key, respectively. The `AWS_DEFAULT_REGION`
and `AWS_SESSION_TOKEN` environment variables are also used, if and `AWS_SESSION_TOKEN` environment variables are also used, if
applicable: applicable:
``` ```hcl
provider "aws" {} provider "aws" {}
``` ```
Usage: Usage:
``` ```hcl
$ export AWS_ACCESS_KEY_ID="anaccesskey" $ export AWS_ACCESS_KEY_ID="anaccesskey"
$ export AWS_SECRET_ACCESS_KEY="asecretkey" $ export AWS_SECRET_ACCESS_KEY="asecretkey"
$ export AWS_DEFAULT_REGION="us-west-2" $ export AWS_DEFAULT_REGION="us-west-2"
@ -91,7 +91,7 @@ method also supports a `profile` configuration and matching
Usage: Usage:
``` ```hcl
provider "aws" { provider "aws" {
region = "us-west-2" region = "us-west-2"
shared_credentials_file = "/Users/tf_user/.aws/creds" shared_credentials_file = "/Users/tf_user/.aws/creds"
@ -120,7 +120,7 @@ using the supplied credentials.
Usage: Usage:
``` ```hcl
provider "aws" { provider "aws" {
assume_role { assume_role {
role_arn = "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME" role_arn = "arn:aws:iam::ACCOUNT_ID:role/ROLE_NAME"

View File

@ -17,7 +17,7 @@
<li<%= sidebar_current("docs-aws-datasource-acm-certificate") %>> <li<%= sidebar_current("docs-aws-datasource-acm-certificate") %>>
<a href="/docs/providers/aws/d/acm_certificate.html">aws_acm_certificate</a> <a href="/docs/providers/aws/d/acm_certificate.html">aws_acm_certificate</a>
</li> </li>
<li<%= sidebar_current("docs-aws-datasource-alb") %>> <li<%= sidebar_current("docs-aws-datasource-alb-x") %>>
<a href="/docs/providers/aws/d/alb.html">aws_alb</a> <a href="/docs/providers/aws/d/alb.html">aws_alb</a>
</li> </li>
<li<%= sidebar_current("docs-aws-datasource-alb-listener") %>> <li<%= sidebar_current("docs-aws-datasource-alb-listener") %>>
@ -116,16 +116,16 @@
<li<%= sidebar_current("docs-aws-datasource-sns-topic") %>> <li<%= sidebar_current("docs-aws-datasource-sns-topic") %>>
<a href="/docs/providers/aws/d/sns_topic.html">aws_sns_topic</a> <a href="/docs/providers/aws/d/sns_topic.html">aws_sns_topic</a>
</li> </li>
<li<%= sidebar_current("docs-aws-datasource-subnet") %>> <li<%= sidebar_current("docs-aws-datasource-subnet-x") %>>
<a href="/docs/providers/aws/d/subnet.html">aws_subnet</a> <a href="/docs/providers/aws/d/subnet.html">aws_subnet</a>
</li> </li>
<li<%= sidebar_current("docs-aws-datasource-subnet-ids") %>> <li<%= sidebar_current("docs-aws-datasource-subnet-ids") %>>
<a href="/docs/providers/aws/d/subnet_ids.html">aws_subnet_ids</a> <a href="/docs/providers/aws/d/subnet_ids.html">aws_subnet_ids</a>
</li> </li>
<li<%= sidebar_current("docs-aws-datasource-vpc") %>> <li<%= sidebar_current("docs-aws-datasource-vpc-x") %>>
<a href="/docs/providers/aws/d/vpc.html">aws_vpc</a> <a href="/docs/providers/aws/d/vpc.html">aws_vpc</a>
</li> </li>
<li<%= sidebar_current("docs-aws-datasource-vpc-endpoint") %>> <li<%= sidebar_current("docs-aws-datasource-vpc-endpoint-x") %>>
<a href="/docs/providers/aws/d/vpc_endpoint.html">aws_vpc_endpoint</a> <a href="/docs/providers/aws/d/vpc_endpoint.html">aws_vpc_endpoint</a>
</li> </li>
<li<%= sidebar_current("docs-aws-datasource-vpc-endpoint-service") %>> <li<%= sidebar_current("docs-aws-datasource-vpc-endpoint-service") %>>