pulumi-aws icon indicating copy to clipboard operation
pulumi-aws copied to clipboard

aws.elasticache.ReplicationGroup type error

Open javier-accruemoney opened this issue 1 year ago • 8 comments

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

javier-accruemoney avatar Aug 01 '24 16:08 javier-accruemoney

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

corymhall avatar Aug 01 '24 16:08 corymhall

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 avatar Aug 01 '24 16:08 javier-accruemoney

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

javier-accruemoney avatar Aug 01 '24 16:08 javier-accruemoney

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

corymhall avatar Aug 02 '24 12:08 corymhall

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

javier-accruemoney avatar Aug 07 '24 01:08 javier-accruemoney

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

corymhall avatar Aug 07 '24 13:08 corymhall

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.

t0yv0 avatar Aug 08 '24 16:08 t0yv0

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

akgoel18 avatar Aug 28 '24 08:08 akgoel18