GoogleCloudPlatform / terraformer

CLI tool to generate terraform files from existing infrastructure (reverse Terraform). Infrastructure to Code
Apache License 2.0
12.58k stars 1.64k forks source link

Trouble importing individual AWS resources #1655

Closed bekahmark12 closed 1 year ago

bekahmark12 commented 1 year ago

Hi there, I am trying to import individaul AWS resources. For example, I am currently trying a wafv2 association. When I tried to import by arn, I got the error:

2023-02-28T00:04:48.681Z [ERROR] plugin.terraform-provider-aws_v4.56.0_x5: Response contains error diagnostic: diagnostic_severity=ERROR tf_provider_addr=registry.terraform.io/hashicorp/aws tf_req_id=0e3ff0c1-a3d9-83d9-89f8-19904c45f12c tf_rpc=ReadResource @module=sdk.proto diagnostic_detail="" diagnostic_summary="unexpected format for ID, expected WEB-ACL-ARN,RESOURCE-ARN" tf_proto_version=5.3 tf_resource_type=aws_wafv2_web_acl_association @caller=github.com/hashicorp/terraform-plugin-go@v0.14.3/tfprotov5/internal/diag/diagnostics.go:55 timestamp=2023-02-28T00:04:48.636Z

When I try to pass in its desired format of WEB-ACL-ARN,RESOURCE-ARN (which follows the terraform import pattern for this resource), it simply tries to import the entire WAF instead of just the association. Here is an example import statement I have tried, one of many variations:

terraformer import aws --resources=wafv2_regional --filter="Type=aws_wafv2_web_acl_association;Name=id;Value='{ my web acl arn},{my resource arn}'"

I am having a very hard time finding documentation on how to import individual AWS resources, specifically which identifiers are needed for each one to pass to terraformer in the filter. I believed they would follow the terraform import pattern but found that not all do, for example the web acl I imported with an arn and terraform requires something totally different for import, but it worked with terraformer. Where can I find docs on how to import each individual aws resource?

laurie-kepford commented 1 year ago

I am having a similar problem. I want to import a single eks cluster. Its name is sandbox and it is tagged with tfimport=yes.

I have tried: terraformer import aws --resources=eks --filter="Name=tag.tfimport;Value=yes" terraformer import aws --resources=eks --filter="aws_eks_cluster=sandbox" terraformer import aws --resources=eks --filter="tag:tfimport=yes"

Each one returns all my clusters and their associated nodegroups

laurie-kepford commented 1 year ago

I finally found one that did work: terraformer import aws --resources=eks --filter="Name=name;Value=sandbox"

Seems so obvious now...

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 7 days with no activity.