pulumi / pulumi-aws

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

aws.elasticache.ReplicationGroup type error #4339

Open javier-accruemoney opened 1 month ago

javier-accruemoney commented 1 month ago

Describe what happened

While trying to update an Elasticache Replication Group have a type mismatch error:

Sample program

new aws.elasticache.ReplicationGroup(name, {
        applyImmediately: true,
        automaticFailoverEnabled: false,
        clusterMode: 'disabled',
        engineVersion: '7.0',
        nodeType: ElasticacheNodeType,
        multiAzEnabled: false,
        numCacheClusters: 1,
        port: 6379,
        description: 'Redis replication groups',
        snapshotRetentionLimit: 30,
        securityGroupIds: [**redisSecurityGroupID**],
        subnetGroupName: **subnetGroup.name**,
        replicationGroupId: name,
      });

Log output

Diagnostics: aws:elasticache:ReplicationGroup (XXXXXXXXX): error: unmarshaling urn:pulumi:XXXXX::XXXX::aws:elasticache/replicationGroup:ReplicationGroup::XXXXXXXX instance state: could not read field cluster_mode: '' expected type 'string', got unconvertible type 'map[string]interface {}', value: 'map[numNodeGroups:1 replicasPerNodeGroup:0]'

Affected Resource(s)

aws.elasticache.ReplicationGroup

Output of pulumi about

CLI Version 3.108.0 Go Version go1.22.0 Go Compiler gc

Plugins NAME VERSION aws 6.47.0 awsx 2.13.0 datadog 4.31.0 docker 4.5.5 docker 3.6.1 nodejs unknown

Host OS darwin Version 14.4.1 Arch arm64

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

corymhall commented 1 month ago

@javier-accruemoney you mention that the error occurs during an update, can you provide the before/after configuration that you used? Thanks!

javier-accruemoney commented 1 month ago

Elasticache replication group configuration was not changed, even though, during pulumi preview got the unmarshaling error.

Just tested with release v6.45.0 and issue is not preset, it starts with v6.46.0

javier-accruemoney commented 1 month ago

https://github.com/hashicorp/terraform-provider-aws/pull/38476/files#diff-692ae398aa74e6339608743df634eab91ce3a4e1987f183156162ca9e34e598fR26 seems the problem comes from upstream

corymhall commented 1 month ago

@javier-accruemoney what version of pulumi-aws & pulumi was the cluster created with? I tested creating with 6.47.0 and I tested creating with 6.45.0 and updating to 6.46.0 and wasn't able to reproduce. I'm assuming there is some upgrade issue, but you need to have used a certain prior version.

javier-accruemoney commented 1 month ago

That's correct, those resources have more than a year of created and can't tell with which was the version from where those resources where created, but the last working one is 6.45.0

corymhall commented 1 month ago

@javier-accruemoney if you run pulumi stack export and then find the ReplicationGroup resource it should have a provider entry with the version of the aws provider used.

t0yv0 commented 1 month ago

It appears there is some complicated upstream evolution history here that might be causing this problem.

https://github.com/hashicorp/terraform-provider-aws/commit/a00ceec58405fb4f1ed0989f815e51b72d05b179 removes cluster_mode parameter that had a complex type

https://github.com/hashicorp/terraform-provider-aws/commit/f893c221f533205c3f59588686858dec3a5316b8 reintroduces cluster_mode of string type

Pulumi bridged provider inherited these changes. I suspect the users of the TF provider may also be affected here. Ideally, the upgrades could have been supported by writing state migration code that automatically moves over user states to the new schema for the resource, but it appears this has not been done in the case of this resource.

To quickly workaround the issue state surgery, pulumi stack export, edit the state by manually migrating it to the new expected shape, followed by pulumi stack import.

akgoel18 commented 2 weeks ago
CLI          
Version      3.121.0
Go Version   go1.22.4
Go Compiler  gc

Host     
OS       darwin
Version  14.5
Arch     arm64

Backend        
Name           pulumi.com
URL            https://app.pulumi.com
User           Unknown
Organizations  
Token type     personal

pulumi about command output should look like this