Skip to content

Commit

Permalink
Merge pull request #32602 from hashicorp/d-import-codeblock-console
Browse files Browse the repository at this point in the history
docs: Add import blocks
  • Loading branch information
YakDriver authored Jul 20, 2023
2 parents 3dff744 + 37bf16f commit f4669bd
Show file tree
Hide file tree
Showing 1,142 changed files with 13,159 additions and 2,451 deletions.
2 changes: 1 addition & 1 deletion .ci/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/hashicorp/terraform-provider-aws/tools
go 1.20

require (
github.com/YakDriver/tfproviderdocs v0.9.0
github.com/YakDriver/tfproviderdocs v0.11.0
github.com/client9/misspell v0.3.4
github.com/golangci/golangci-lint v1.53.3
github.com/hashicorp/copywrite v0.16.4
Expand Down
4 changes: 2 additions & 2 deletions .ci/tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ github.com/OpenPeeDeeP/depguard/v2 v2.1.0/go.mod h1:PUBgk35fX4i7JDmwzlJwJ+GMe6Nf
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7/go.mod h1:z4/9nQmJSSwwds7ejkxaJwO37dru3geImFUdJlaLzQo=
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwFc0ih8puEVAOFGELsn1zoIIYdxvML7mDxA=
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g=
github.com/YakDriver/tfproviderdocs v0.9.0 h1:31iObK2t5W5/AMwOzm3IH1niNVomDFeBLMLjDO+mD8Q=
github.com/YakDriver/tfproviderdocs v0.9.0/go.mod h1:cmvxw7mRCeXngkZzN5rgygQqujN0irc5OJOCPfOJ9cQ=
github.com/YakDriver/tfproviderdocs v0.11.0 h1:IIdqZ/7ZpZ8V8EK33b8APQuVWqdgSV2HbAWxttljEKw=
github.com/YakDriver/tfproviderdocs v0.11.0/go.mod h1:cmvxw7mRCeXngkZzN5rgygQqujN0irc5OJOCPfOJ9cQ=
github.com/acomagu/bufpipe v1.0.3 h1:fxAGrHZTgQ9w5QqVItgzwj235/uYZYgbXitB+dLupOk=
github.com/acomagu/bufpipe v1.0.3/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4=
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
Expand Down
8 changes: 4 additions & 4 deletions docs/running-and-writing-acceptance-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export AWS_DEFAULT_REGION=us-gov-west-1
Tests can then be run by specifying a regular expression defining the tests to
run and the package in which the tests are defined:

```sh
$ make testacc TESTS=TestAccCloudWatchDashboard_updateName PKG=cloudwatch
```console
% make testacc TESTS=TestAccCloudWatchDashboard_updateName PKG=cloudwatch
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cloudwatch/... -v -count 1 -parallel 20 -run=TestAccCloudWatchDashboard_updateName -timeout 180m
=== RUN TestAccCloudWatchDashboard_updateName
Expand All @@ -78,8 +78,8 @@ write the regular expression. For example, to run all tests of the
`aws_cloudwatch_dashboard` resource rather than just the updateName test, you
can start testing like this:

```sh
$ make testacc TESTS=TestAccCloudWatchDashboard PKG=cloudwatch
```console
% make testacc TESTS=TestAccCloudWatchDashboard PKG=cloudwatch
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cloudwatch/... -v -count 1 -parallel 20 -run=TestAccCloudWatchDashboard -timeout 180m
=== RUN TestAccCloudWatchDashboard_basic
Expand Down
8 changes: 4 additions & 4 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ the example's own directory.

For example:

```
$ git clone https://github.com/hashicorp/terraform-provider-aws
$ cd terraform-provider-aws/examples/two-tier
$ terraform apply
```console
% git clone https://github.com/hashicorp/terraform-provider-aws
% cd terraform-provider-aws/examples/two-tier
% terraform apply
...
```
18 changes: 16 additions & 2 deletions website/docs/d/iam_server_certificate.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,19 @@ This data source exports the following attributes in addition to the arguments a

## Import

The terraform import function will read in certificate body, certificate chain (if it exists), id, name, path, and arn.
It will not retrieve the private key which is not available through the AWS API.
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import an IAM server certificate using `name`. For example:

```terraform
import {
to = aws_iam_server_certificate.example
id = "example"
}
```

Using `terraform import`, import an IAM server certificate using `name`. For example:

```console
% terraform import aws_iam_server_certificate.example example
```

Import will read in the certificate body, certificate chain (if it exists), ID, name, path, and ARN. It will not retrieve the private key which is not available through the AWS API.
8 changes: 4 additions & 4 deletions website/docs/d/kms_secrets.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ If you do not already have a `CiphertextBlob` from encrypting a KMS secret, you
-> If you have a newline character at the end of your file, it will be decrypted with this newline character intact. For most use cases this is undesirable and leads to incorrect passwords or invalid values, as well as possible changes in the plan. Be sure to use `echo -n` if necessary.
-> If you are using asymmetric keys ensure you are using the right encryption algorithm when you encrypt and decrypt else you will get IncorrectKeyException during the decrypt phase.

```sh
$ echo -n 'master-password' > plaintext-password
$ aws kms encrypt --key-id ab123456-c012-4567-890a-deadbeef123 --plaintext fileb://plaintext-password --encryption-context foo=bar --output text --query CiphertextBlob
```console
% echo -n 'master-password' > plaintext-password
% aws kms encrypt --key-id ab123456-c012-4567-890a-deadbeef123 --plaintext fileb://plaintext-password --encryption-context foo=bar --output text --query CiphertextBlob
AQECAHgaPa0J8WadplGCqqVAr4HNvDaFSQ+NaiwIBhmm6qDSFwAAAGIwYAYJKoZIhvcNAQcGoFMwUQIBADBMBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDI+LoLdvYv8l41OhAAIBEIAfx49FFJCLeYrkfMfAw6XlnxP23MmDBdqP8dPp28OoAQ==
$ aws kms encrypt --key-id ab123456-c012-4567-890a-deadbeef123 --plaintext fileb://plaintext-password --encryption-algorithm RSAES_OAEP_SHA_256 --output text --query CiphertextBlob
% aws kms encrypt --key-id ab123456-c012-4567-890a-deadbeef123 --plaintext fileb://plaintext-password --encryption-algorithm RSAES_OAEP_SHA_256 --output text --query CiphertextBlob
AQECAHgaPa0J8WadplGCqqVAr4HNvDaFSQ+NaiwIBhmm6qDSFwAAAGIwYAYJKoZIhvcNAQcGoFMwUQIBADBMBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDI+LoLdvYv8l41OhAAIBEIAfx49FFJCLeYrkfMfAw6XlnxP23MmDBdqP8dPp28OoAQ==
```

Expand Down
40 changes: 20 additions & 20 deletions website/docs/guides/version-4-upgrade.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ resource "aws_s3_bucket" "example" {

Terraform CLI with v4.9.0 of the AWS Provider will report back:

```shell
```console
aws_s3_bucket.example: Refreshing state... [id=yournamehere]
...
No changes. Your infrastructure matches the configuration.
Expand Down Expand Up @@ -1379,7 +1379,7 @@ resource "aws_s3_bucket_accelerate_configuration" "example" {

Run `terraform import` on each new resource, _e.g._,

```shell
```console
$ terraform import aws_s3_bucket_accelerate_configuration.example yournamehere
aws_s3_bucket_accelerate_configuration.example: Importing from ID "yournamehere"...
aws_s3_bucket_accelerate_configuration.example: Import prepared!
Expand Down Expand Up @@ -1437,7 +1437,7 @@ resource "aws_s3_bucket_acl" "example" {

Run `terraform import` on each new resource, _e.g._,

```shell
```console
$ terraform import aws_s3_bucket_acl.example yournamehere,private
aws_s3_bucket_acl.example: Importing from ID "yournamehere,private"...
aws_s3_bucket_acl.example: Import prepared!
Expand Down Expand Up @@ -1508,7 +1508,7 @@ resource "aws_s3_bucket_cors_configuration" "example" {

Run `terraform import` on each new resource, _e.g._,

```shell
```console
$ terraform import aws_s3_bucket_cors_configuration.example yournamehere
aws_s3_bucket_cors_configuration.example: Importing from ID "yournamehere"...
aws_s3_bucket_cors_configuration.example: Import prepared!
Expand Down Expand Up @@ -1605,7 +1605,7 @@ resource "aws_s3_bucket_acl" "example" {

Run `terraform import` on each new resource, _e.g._,

```shell
```console
$ terraform import aws_s3_bucket_acl.example yournamehere
aws_s3_bucket_acl.example: Importing from ID "yournamehere"...
aws_s3_bucket_acl.example: Import prepared!
Expand Down Expand Up @@ -1708,7 +1708,7 @@ resource "aws_s3_bucket_lifecycle_configuration" "example" {

Run `terraform import` on each new resource, _e.g._,

```shell
```console
$ terraform import aws_s3_bucket_lifecycle_configuration.example yournamehere
aws_s3_bucket_lifecycle_configuration.example: Importing from ID "yournamehere"...
aws_s3_bucket_lifecycle_configuration.example: Import prepared!
Expand Down Expand Up @@ -1791,7 +1791,7 @@ resource "aws_s3_bucket_lifecycle_configuration" "example" {

Run `terraform import` on each new resource, _e.g._,

```shell
```console
$ terraform import aws_s3_bucket_lifecycle_configuration.example yournamehere
aws_s3_bucket_lifecycle_configuration.example: Importing from ID "yournamehere"...
aws_s3_bucket_lifecycle_configuration.example: Import prepared!
Expand Down Expand Up @@ -1878,7 +1878,7 @@ resource "aws_s3_bucket_lifecycle_configuration" "example" {

Run `terraform import` on each new resource, _e.g._,

```shell
```console
$ terraform import aws_s3_bucket_lifecycle_configuration.example yournamehere
aws_s3_bucket_lifecycle_configuration.example: Importing from ID "yournamehere"...
aws_s3_bucket_lifecycle_configuration.example: Import prepared!
Expand Down Expand Up @@ -2010,7 +2010,7 @@ resource "aws_s3_bucket_lifecycle_configuration" "example" {

Run `terraform import` on each new resource, _e.g._,

```shell
```console
$ terraform import aws_s3_bucket_lifecycle_configuration.example yournamehere
aws_s3_bucket_lifecycle_configuration.example: Importing from ID "yournamehere"...
aws_s3_bucket_lifecycle_configuration.example: Import prepared!
Expand Down Expand Up @@ -2083,7 +2083,7 @@ resource "aws_s3_bucket_logging" "example" {

Run `terraform import` on each new resource, _e.g._,

```shell
```console
$ terraform import aws_s3_bucket_logging.example yournamehere
aws_s3_bucket_logging.example: Importing from ID "yournamehere"...
aws_s3_bucket_logging.example: Import prepared!
Expand Down Expand Up @@ -2157,7 +2157,7 @@ resource "aws_s3_bucket_object_lock_configuration" "example" {

Run `terraform import` on each new resource, _e.g._,

```shell
```console
$ terraform import aws_s3_bucket_object_lock_configuration.example yournamehere
aws_s3_bucket_object_lock_configuration.example: Importing from ID "yournamehere"...
aws_s3_bucket_object_lock_configuration.example: Import prepared!
Expand Down Expand Up @@ -2247,7 +2247,7 @@ EOF

Run `terraform import` on each new resource, _e.g._,

```shell
```console
$ terraform import aws_s3_bucket_policy.example yournamehere
aws_s3_bucket_policy.example: Importing from ID "yournamehere"...
aws_s3_bucket_policy.example: Import prepared!
Expand Down Expand Up @@ -2359,7 +2359,7 @@ resource "aws_s3_bucket_replication_configuration" "example" {

Run `terraform import` on each new resource, _e.g._,

```shell
```console
$ terraform import aws_s3_bucket_replication_configuration.example yournamehere
aws_s3_bucket_replication_configuration.example: Importing from ID "yournamehere"...
aws_s3_bucket_replication_configuration.example: Import prepared!
Expand Down Expand Up @@ -2417,7 +2417,7 @@ resource "aws_s3_bucket_request_payment_configuration" "example" {

Run `terraform import` on each new resource, _e.g._,

```shell
```console
$ terraform import aws_s3_bucket_request_payment_configuration.example yournamehere
aws_s3_bucket_request_payment_configuration.example: Importing from ID "yournamehere"...
aws_s3_bucket_request_payment_configuration.example: Import prepared!
Expand Down Expand Up @@ -2488,7 +2488,7 @@ resource "aws_s3_bucket_server_side_encryption_configuration" "example" {

Run `terraform import` on each new resource, _e.g._,

```shell
```console
$ terraform import aws_s3_bucket_server_side_encryption_configuration.example yournamehere
aws_s3_bucket_server_side_encryption_configuration.example: Importing from ID "yournamehere"...
aws_s3_bucket_server_side_encryption_configuration.example: Import prepared!
Expand Down Expand Up @@ -2554,7 +2554,7 @@ resource "aws_s3_bucket_versioning" "example" {

Run `terraform import` on each new resource, _e.g._,

```shell
```console
$ terraform import aws_s3_bucket_versioning.example yournamehere
aws_s3_bucket_versioning.example: Importing from ID "yournamehere"...
aws_s3_bucket_versioning.example: Import prepared!
Expand Down Expand Up @@ -2662,7 +2662,7 @@ resource and remove `versioning` and its nested arguments in the `aws_s3_bucket`

Run `terraform import` on each new resource, _e.g._,

```shell
```console
$ terraform import aws_s3_bucket_versioning.example yournamehere
aws_s3_bucket_versioning.example: Importing from ID "yournamehere"...
aws_s3_bucket_versioning.example: Import prepared!
Expand Down Expand Up @@ -2758,7 +2758,7 @@ resource "aws_s3_bucket_website_configuration" "example" {

Run `terraform import` on each new resource, _e.g._,

```shell
```console
$ terraform import aws_s3_bucket_website_configuration.example yournamehere
aws_s3_bucket_website_configuration.example: Importing from ID "yournamehere"...
aws_s3_bucket_website_configuration.example: Import prepared!
Expand Down Expand Up @@ -3552,5 +3552,5 @@ be compatible with EC2-Classic as AWS completes their EC2-Classic networking ret

These resources should be considered deprecated and will be removed in version 5.0.0.

* [Account Associations](/docs/providers/aws/r/macie_member_account_association.html)
* [S3 Bucket Associations](/docs/providers/aws/r/macie_s3_bucket_association.html)
* Macie Member Account Association
* Macie S3 Bucket Association
14 changes: 7 additions & 7 deletions website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ For example:
provider "aws" {}
```

```sh
$ export AWS_ACCESS_KEY_ID="anaccesskey"
$ export AWS_SECRET_ACCESS_KEY="asecretkey"
$ export AWS_REGION="us-west-2"
$ terraform plan
```console
% export AWS_ACCESS_KEY_ID="anaccesskey"
% export AWS_SECRET_ACCESS_KEY="asecretkey"
% export AWS_REGION="us-west-2"
% terraform plan
```

Other environment variables related to authorization are:
Expand Down Expand Up @@ -287,8 +287,8 @@ See the assume role documentation [section on web identities](https://docs.aws.a

By default, the underlying AWS client used by the Terraform AWS Provider creates requests with User-Agent headers including information about Terraform and AWS SDK for Go versions. To provide additional information in the User-Agent headers, the `TF_APPEND_USER_AGENT` environment variable can be set and its value will be directly added to HTTP requests. E.g.,

```sh
$ export TF_APPEND_USER_AGENT="JenkinsAgent/i-12345678 BuildID/1234 (Optional Extra Information)"
```console
% export TF_APPEND_USER_AGENT="JenkinsAgent/i-12345678 BuildID/1234 (Optional Extra Information)"
```

## Argument Reference
Expand Down
13 changes: 11 additions & 2 deletions website/docs/r/accessanalyzer_analyzer.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,17 @@ This resource exports the following attributes in addition to the arguments abov

## Import

Import Access Analyzer Analyzers using the `analyzer_name`. For example:
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import Access Analyzer Analyzers using the `analyzer_name`. For example:

```terraform
import {
to = aws_accessanalyzer_analyzer.example
id = "example"
}
```
$ terraform import aws_accessanalyzer_analyzer.example example

Using `terraform import`, import Access Analyzer Analyzers using the `analyzer_name`. For example:

```console
% terraform import aws_accessanalyzer_analyzer.example example
```
13 changes: 11 additions & 2 deletions website/docs/r/accessanalyzer_archive_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,17 @@ This resource exports the following attributes in addition to the arguments abov

## Import

Import AccessAnalyzer ArchiveRule using the `analyzer_name/rule_name`. For example:
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import AccessAnalyzer ArchiveRule using the `analyzer_name/rule_name`. For example:

```terraform
import {
to = aws_accessanalyzer_archive_rule.example
id = "example-analyzer/example-rule"
}
```
$ terraform import aws_accessanalyzer_archive_rule.example example-analyzer/example-rule

Using `terraform import`, import AccessAnalyzer ArchiveRule using the `analyzer_name/rule_name`. For example:

```console
% terraform import aws_accessanalyzer_archive_rule.example example-analyzer/example-rule
```
30 changes: 26 additions & 4 deletions website/docs/r/account_alternate_contact.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,36 @@ This resource exports no additional attributes.

## Import

Import the Alternate Contact for the current account using the `alternate_contact_type`. For example:
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import the Alternate Contact for the current or another account using the `alternate_contact_type`. For example:

Import the Alternate Contact for the current account:

```terraform
import {
to = aws_account_alternate_contact.operations
id = "OPERATIONS"
}
```
$ terraform import aws_account_alternate_contact.operations OPERATIONS

Import the Alternate Contact for another account using the `account_id` and `alternate_contact_type` separated by a forward slash (`/`):

```terraform
import {
to = aws_account_alternate_contact.operations
id = "1234567890/OPERATIONS"
}
```

If you provide an account ID, import the Alternate Contact using the `account_id` and `alternate_contact_type` separated by a forward slash (`/`). For example:
**Using `terraform import` to import** the Alternate Contact for the current or another account using the `alternate_contact_type`. For example:

Import the Alternate Contact for the current account:

```console
% terraform import aws_account_alternate_contact.operations OPERATIONS
```
$ terraform import aws_account_alternate_contact.operations 1234567890/OPERATIONS

Import the Alternate Contact for another account using the `account_id` and `alternate_contact_type` separated by a forward slash (`/`):

```console
% terraform import aws_account_alternate_contact.operations 1234567890/OPERATIONS
```
13 changes: 11 additions & 2 deletions website/docs/r/account_primary_contact.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,17 @@ This resource exports no additional attributes.

## Import

Import the Primary Contact using the `account_id`. For example:
In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import the Primary Contact using the `account_id`. For example:

```terraform
import {
to = aws_account_primary_contact.test
id = "1234567890"
}
```
$ terraform import aws_account_primary_contact.test 1234567890

Using `terraform import`, import the Primary Contact using the `account_id`. For example:

```console
% terraform import aws_account_primary_contact.test 1234567890
```
Loading

0 comments on commit f4669bd

Please sign in to comment.