Search code examples
pythonamazon-web-servicespulumi

The code generated from "pulumi import" lacks a lot of details


I want to use pulumi to import one of my existing resources on AWS.

So I ran pulumi import aws:elasticache/cluster:Cluster my-redis my-redis command and got the following details in the output:

= aws:elasticache/cluster:Cluster: (import) 🔒
    [id=my-redis]
    [urn=urn:pulumi:prod::my_aws_infra::aws:elasticache/cluster:Cluster::my-redis]
    [provider=urn:pulumi:prod::my_aws_infra::pulumi:providers:aws::default_4_0_0::5bcb13d1-6ocf-qb30-bf12-6c7a1683a072]
    availabilityZone      : "ap-northeast-1c"
    azMode                : "single-az"
    clusterId             : "my-redis"
    engine                : "redis"
    engineVersion         : "4.0.10"
    maintenanceWindow     : "sat:20:00-sat:21:00"
    nodeType              : "cache.t3.small"
    notificationTopicArn  : "arn:aws:sns:ap-northeast-1:123456789123:redis_sns_topic"
    numCacheNodes         : 1
    parameterGroupName    : "default.redis4.0"
    port                  : 6379
    securityGroupIds      : [
        [0]: "sg-b6d1b86al301zd054"
        [1]: "sg-5yfa3a33"
    ]
    snapshotRetentionLimit: 0
    snapshotWindow        : "16:30-17:30"
    subnetGroupName       : "default"
    tags                  : {
    }

The code I get from pulumi import ... becomes

my_redis = aws.elasticache.Cluster("my-redis",
    cluster_id="my-redis",
    notification_topic_arn="arn:aws:sns:ap-northeast-1:123456789123:redis_sns_topic",
    opts=pulumi.ResourceOptions(protect=True))

Why does the generated code lack a lot of information (availabilityZone, azMode, engine, etc)?

The code works correctly when I run pulumi up.

How does pulumi know all the configurations of the redis resource?

Are the configurations stored in the backend of pulumi?


Solution

  • In https://github.com/pulumi/pulumi/issues/6856, you can see that one of the developers of pulumi says

    This is the expected behavior. For the purposes of importing the resource to be managed by Pulumi, the necessary inputs are specified in the code generated. You are of course welcome to include the additional details in your code, but Pulumi has generated what is necessary to import the resource.

    To see all of the inputs/outputs of your resources, you can take a look at your state file (pulumi stack export).

    So this is an expected behavior. The developers of pulumi don't want to show all the details in the code by default.

    And currently, there's no way generate a code with all the details.

    Those details are stored in the backend of pulumi. They can be found in .pulumi/stacks/<my-stack>.json in the backend.