从 "pulumi import" 生成的代码缺少很多细节

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

我想使用 pulumi 导入我在 AWS 上的现有资源之一。

所以我 运行 pulumi import aws:elasticache/cluster:Cluster my-redis my-redis 命令并在输出中得到以下详细信息:

= 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                  : {
    }

我从pulumi import ...得到的代码变成了

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))

为什么生成的代码缺少很多信息(availabilityZoneazModeengine 等)?

当我 运行 pulumi up.

时代码工作正常

pulumi如何知道redis资源的所有配置?

配置存储在pulumi后台吗?

https://github.com/pulumi/pulumi/issues/6856中可以看到pulumi的开发者之一说

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).

所以这是预期的行为。 pulumi的开发者不想在代码中默认显示所有细节。

目前,无法生成包含所有详细信息的代码。

这些详细信息存储在 pulumi 的后端。它们可以在后端的 .pulumi/stacks/<my-stack>.json 中找到。