docs/ai-agent-guides/arn-based-resource-identity.md
You are working on the Terraform AWS Provider, specifically focused on adding resource identity to existing ARN-based Plugin SDKV2 resources. This Github issue contains the resources that need resource identity support and have an ARN based identity.
When adding resource identity, all resources in a service should be done in the same pull request. Follow the steps below to complete this task.
f-ri and be suffixed with the name of the service being updated, e.g. f-ri-elbv2. If the current branch does not match this convention, create one.main branch.The changes for each individual resource should be done in its own commit. Use the following steps to add resource identity to an existing resource:
@ArnIdentity annotation to the target resource.CheckExists helper function that accepts 3 parameters rather than 2 (you can check this in the resource's test file), add another annotation to the resource file in the format // @Testing(existsType="github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types;types.TrustStore"), but replacing the type with the correct one for the resource in question. The type should match the third parameter of the CheckExists function.@Testing(preIdentityVersion="v6.3.0"). Use CHANGELOG.md at the project root to determine the most recently released version (which will be the last before identity is added).schema.ImportStatePassthroughContext as StateContext value then remove that importer function declaration as it is no longer necessary.testdata/tmpl directory. For each resource, create a file named <resource>_basic.gtpl (e.g., trust_store_basic.gtpl)._basic test. If populating from the _basic configuration, be sure to replace any string format directives (e.g. name = %[1]q) with a corresponding reference to a variable (e.g. name = var.rName).testdata directory for the service. Do not manually create test directories or files as they will be generated.resource "aws_service_thing" "test" {
{{- template "region" }}
name = var.rName
{{- template "tags" . }}
}
aws_region data source, the region template should also be embedded here.data "aws_region" "current" {
{{- template "region" }}
}
go generate ./internal/service/elbv2/.... This will generate tests for Resource Identity and any required test files.make testacc PKG=<service> TESTS=TestAcc<Resource>_Identity_Basicmake testacc PKG=<service> TESTS=TestAcc<Resource>_Identitymake testacc PKG=<service> TESTS=TestAcc<Resource>_. Always include the PKG parameter to properly scope the tests to the intended service package.terraform fmt. To verify, run terraform fmt -recursive -check, and confirm there is no output.r/aws_lb_target_group: add resource identity. Ensure the commit message body includes the results of the acceptance test run in the previous step.Repeat steps 2 and 3 for each resource in the service. When all resources are complete, proceed to the next section.
In Terraform v1.12.0 and later, the [`import` block](https://developer.hashicorp.com/terraform/language/import) can be used with the `identity` attribute. For example:
```terraform
import {
to = <resource-name>.example
identity = {
"arn" = <example-arn-value>
}
}
resource "<resource-name>" "example" {
### Configuration omitted for brevity ###
}
```
### Identity Schema
#### Required
* `arn` (String) <description here>.
identity, including the identity schema, should appear before instructions for import blocks with an id argument or importing via the CLI.website/docs/r/acm_certificate.html.markdown for a reference implementation.!!!Important!!!: Ask for confirmation before proceeding with this step.
<service-name>", e.g. "Add ARN-based resource identity to elbv2".### Description
Add resource identity to ARN-based resources in `<service-name>`. This includes:
<list Terraform resource names here>
### Relations
Relates #42983
Relates #42984
### Output from Acceptance Testing
<insert acceptance test results here>
.changelog/<pr-number>.txt, and include one enhancement entry per resource. Refer to .changelog/43503.txt for the appropriate formatting.PKG parameter is included in test commands<resource>_basic.gtpl)testAccCheck*Exists helper function has incorrect arguments, add a @Testing(existsType="") annotation. NEVER modify the function signature of an existing "exists" helper functiontestdata/tmpl)identitytests generator is being called within the service's generate.go file. If it isn't, add the following line to generate.go next to the existing go:generate directives.var.rName variable, add an // @Testing(generator=false) annotation to remove it from the generated configuration.//go:generate go run ../../generate/identitytests/main.go
existsType annotationImportStatePassthroughContext