简体   繁体   中英

How I can solve this error when importing aws.alb.TargetGroup using Pulumi Cli

I try to import existing resources to Pulumi. I execute following command on my terminal.

$ pulumi import aws:alb/targetGroup:TargetGroup target-group-name target-group-arn

But I had following error.

error: internal error: Error: cannot assign expression of type tuple(cty.NullVal(cty.DynamicPseudoType)) to location of type union(list(union(object({onDeregistration = union(output(string), string, annotated(0x14001d12b40)), onUnhealthy = union(output(string), string, annotated(0x14001d12b80))}, annotated(0x14001d12b00)), output(object({onDeregistration = string, onUnhealthy = string}, annotated(0x14001d12bc0))), annotated(0x14001d12c00))), none, output(list(object({onDeregistration = string, onUnhealthy = string}, annotated(0x14001d12bc0)))), annotated(0x14001d12cc0)):

  on anonymous.pp line 22:
  23:     targetFailovers =[
  24:         null]

I can't solve this error. Please teach me how to solve. Or please teach me how to generate typescript code from pulumi state. Because importing was success.

appendix My environment is:

  • OS
    • macOS Monterey v12.5
  • Arch
    • m2
  • pulumi version
    • v3.51.1
  • which pulumi
    • /opt/homebrew/bin/pulumi
  • pulumi runtime
    • nodejs(TypeScript)

Looking at the docs https://www.pulumi.com/docs/guides/adopting/import/ - the command should look like this:

pulumi import aws:s3/bucket:Bucket infra-logs company-infra-logs

when infra-logs is the resource name for your Pulumi program, and company-infra-logs is the bucket name.

In your case, when importing a Target Group an ARN is expected instead of the resource name.

I've tried fetching a target group like this:

pulumi import aws:alb/targetGroup:TargetGroup test-tg <ARN>

And it worked for me.

Couple of key notes for you to validate:

  1. Make sure that the ARN is copied correctly, the ARN is built as follows:

    arn:aws:elasticloadbalancing::<ACCOUNT_ID>:targetgroup/<TARGET_GROUP_NAME>/

  2. Make sure your pulumi stack is in the same region as your target group

  3. Make sure your AWS credentials are configured properly (you might be on the wrong profile, or wrong account)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM