pulumi / pulumi-aws

An Amazon Web Services (AWS) Pulumi resource package, providing multi-language access to AWS
Apache License 2.0
459 stars 155 forks source link

Import existing resources and got CacheClusterNotFound error even it exists #2124

Closed thailowki closed 1 year ago

thailowki commented 2 years ago

What happened?

Hey Pulumi, I have a few Elastic Clusters (on AWS) and I am trying to import them to Pulumi. The problem is that some of them are about to be detected by Pulumi and some are not. I am wondering why? Here is the example

admin-gateway and infra-storage-thai-test-v2 are both in same aws account and same region (us-west-2). Pulumi was able to generate code for admin-gateway:

thaipham@N9GK65GXW1 quickstart % pulumi import aws:elasticache/cluster:Cluster admin-gateway admin-gateway                          
Previewing import (dev)

View Live: https://app.pulumi.com/thailowki/quickstart/dev/previews/2189eee2-316c-4e2d-a50f-ab03a68c4194

     Type                        Name            Plan       
 +   pulumi:pulumi:Stack         quickstart-dev  create     
 =   └─ aws:elasticache:Cluster  admin-gateway   import     

Resources:
    + 1 to create
    = 1 to import
    2 changes

Do you want to perform this import? details

but not for the other :

thaipham@N9GK65GXW1 quickstart % pulumi import aws:elasticache/cluster:Cluster infra-storage-thai-test-v2 infra-storage-thai-test-v2
Previewing import (dev)

View Live: https://app.pulumi.com/thailowki/quickstart/dev/previews/a5490dc5-985d-49d7-ad67-928e331dc742

     Type                        Name                        Plan       Info
 +   pulumi:pulumi:Stack         quickstart-dev              create     1 error
 =   └─ aws:elasticache:Cluster  infra-storage-thai-test-v2  import     1 error

Diagnostics:
  pulumi:pulumi:Stack (quickstart-dev):
    error: preview failed

  aws:elasticache:Cluster (infra-storage-thai-test-v2):
    error: Preview failed: resource 'infra-storage-thai-test-v2' does not exist

Here is the log file: thaipham@N9GK65GXW1.log

Steps to reproduce

Using the command pulumi import aws:elasticache/cluster:Cluster infra-storage-thai-test-v2 infra-storage-thai-test-v2

Expected Behavior

About to generate code to import existing resource.

Actual Behavior

pulumi:pulumi:Stack (quickstart-dev): error: preview failed

aws:elasticache:Cluster (infra-storage-thai-test-v2): error: Preview failed: resource 'infra-storage-thai-test-v2' does not exist

Output of pulumi about

CLI
Version 3.38.0 Go Version go1.19 Go Compiler gc

Plugins NAME VERSION aws 5.9.2 go unknown

Host
OS darwin Version 12.5.1 Arch arm64

This project is written in go: executable='/usr/local/go/bin/go' version='go version go1.19 darwin/arm64'

Current Stack: dev

TYPE URN pulumi:pulumi:Stack urn:pulumi:dev::quickstart::pulumi:pulumi:Stack::quickstart-dev pulumi:providers:aws urn:pulumi:dev::quickstart::pulumi:providers:aws::default_5_9_2 aws:elasticache/cluster:Cluster urn:pulumi:dev::quickstart::aws:elasticache/cluster:Cluster::gater

Found no pending operations associated with dev

Backend
Name pulumi.com URL https://app.pulumi.com/thailowki User thailowki Organizations thailowki

Dependencies: NAME VERSION github.com/pulumi/pulumi-aws/sdk/v5 5.9.2 github.com/pulumi/pulumi/sdk/v3 3.35.3

Pulumi locates its logs in /var/folders/wm/sqsss00j4l789_gkcqhtlr3w0000gn/T/ by default

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

stack72 commented 2 years ago

Hi @thailowki

If you use the AWS CLi, are you able to describe both resources?

Paul

thailowki commented 2 years ago

Hi @stack72 ,

I was able to describe admin-gateway and couldnt for infra-storage-thai-test-v2

thaipham@N9GK65GXW1 quickstart % aws elasticache describe-cache-clusters --cache-cluster-id admin-gateway
{
    "CacheClusters": [
        {
            "CacheClusterId": "admin-gateway",
            "ClientDownloadLandingPage": "https://console.aws.amazon.com/elasticache/home#client-download:",
            "CacheNodeType": "cache.m3.xlarge",
            "Engine": "redis",
            "EngineVersion": "3.2.10",
            "CacheClusterStatus": "available",
            "NumCacheNodes": 1,
            "PreferredAvailabilityZone": "us-west-2a",
            "CacheClusterCreateTime": "2019-05-08T20:36:40.725000+00:00",
            "PreferredMaintenanceWindow": "fri:10:30-fri:11:30",
            "PendingModifiedValues": {},
            "CacheSecurityGroups": [],
            "CacheParameterGroup": {
                "CacheParameterGroupName": "default.redis3.2",
                "ParameterApplyStatus": "in-sync",
                "CacheNodeIdsToReboot": []
            },
            "CacheSubnetGroupName": "default",
            "AutoMinorVersionUpgrade": true,
            "SecurityGroups": [
                {
                    "SecurityGroupId": "sg-34a9db52",
                    "Status": "active"
                }
            ],
            "SnapshotRetentionLimit": 0,
            "SnapshotWindow": "09:00-10:00",
            "AuthTokenEnabled": false,
            "TransitEncryptionEnabled": false,
            "AtRestEncryptionEnabled": false,
            "ARN": "arn:aws:elasticache:us-west-2:611706558220:cluster:admin-gateway",
            "ReplicationGroupLogDeliveryEnabled": false,
            "LogDeliveryConfigurations": []
        }
    ]
}
thaipham@N9GK65GXW1 quickstart % aws elasticache describe-cache-clusters --cache-cluster-id infra-storage-thai-test-v2      

An error occurred (CacheClusterNotFound) when calling the DescribeCacheClusters operation: CacheCluster not found: infra-storage-thai-test-v2
stack72 commented 2 years ago

Hi @thailowki

If the AWS CLI is not able to describe it then we are not going to be able to read it either I'm afraid. I think there's something incorrect with your configuration

I can close this out and if you still get the same behaviour when you get the CLI working, then w can revisit if Pulumi can't find it

Sorry to not be more help here

Paul