diff --git a/examples/examples_test.go b/examples/examples_test.go index d7497b8fad1..ecaa297bb6e 100644 --- a/examples/examples_test.go +++ b/examples/examples_test.go @@ -105,290 +105,425 @@ func replay(t *testing.T, sequence string) { // Updated in https://github.com/pulumi/pulumi-aws/pull/3881 to accept CHANGES_SOME so long as they are not // replacements. func TestMigrateRdsInstance(t *testing.T) { - replay(t, `[ - { - "method": "/pulumirpc.ResourceProvider/Diff", - "request": { - "id": "postgresdb8a8a6f1", - "urn": "urn:pulumi:dev::ts::aws:rds/instance:Instance::postgresdb", - "olds": { - "__meta": "{\"e2bfb730-ecaa-11e6-8f88-34363bc7c4c0\":{\"create\":2400000000000,\"delete\":3600000000000,\"update\":4800000000000},\"schema_version\":\"1\"}", - "address": "postgresdb8a8a6f1.chuqccm8uxqx.us-west-2.rds.amazonaws.com", - "allocatedStorage": 30, - "applyImmediately": false, - "arn": "arn:aws:rds:us-west-2:616138583583:db:postgresdb8a8a6f1", - "autoMinorVersionUpgrade": true, - "availabilityZone": "us-west-2d", - "backupRetentionPeriod": 0, - "backupWindow": "06:15-06:45", - "caCertIdentifier": "rds-ca-2019", - "characterSetName": "", - "copyTagsToSnapshot": false, - "customIamInstanceProfile": "", - "customerOwnedIpEnabled": false, - "dbName": "airflow", - "dbSubnetGroupName": "default", - "deleteAutomatedBackups": true, - "deletionProtection": false, - "domain": "", - "domainIamRoleName": "", - "enabledCloudwatchLogsExports": [], - "endpoint": "postgresdb8a8a6f1.chuqccm8uxqx.us-west-2.rds.amazonaws.com:5432", - "engine": "postgres", - "engineVersion": "15.3", - "engineVersionActual": "15.3", - "hostedZoneId": "Z1PVIF0B656C1W", - "iamDatabaseAuthenticationEnabled": false, - "id": "postgresdb8a8a6f1", - "identifier": "postgresdb8a8a6f1", - "identifierPrefix": "", - "instanceClass": "db.t4g.micro", - "iops": 0, - "kmsKeyId": "", - "latestRestorableTime": "", - "licenseModel": "postgresql-license", - "listenerEndpoints": [], - "maintenanceWindow": "sun:07:16-sun:07:46", - "masterUserSecrets": [], - "maxAllocatedStorage": 0, - "monitoringInterval": 0, - "monitoringRoleArn": "", - "multiAz": false, - "name": "airflow", - "ncharCharacterSetName": "", - "networkType": "IPV4", - "optionGroupName": "default:postgres-15", - "parameterGroupName": "default.postgres15", - "password": "tuFp574p9Arw58gu", - "performanceInsightsEnabled": false, - "performanceInsightsKmsKeyId": "", - "performanceInsightsRetentionPeriod": 0, - "port": 5432, - "publiclyAccessible": false, - "replicaMode": "", - "replicas": [], - "replicateSourceDb": "", - "resourceId": "db-DUPUZANEFBXYECMTI2B5RZPTOE", - "securityGroupNames": [], - "skipFinalSnapshot": true, - "status": "available", - "storageEncrypted": false, - "storageThroughput": 0, - "storageType": "gp2", - "tags": {}, - "tagsAll": {}, - "timezone": "", - "username": "airflow", - "vpcSecurityGroupIds": [ - "sg-4d436f12" - ] - }, - "news": { - "__defaults": [ - "applyImmediately", - "autoMinorVersionUpgrade", - "copyTagsToSnapshot", - "deleteAutomatedBackups", - "identifier", - "monitoringInterval", - "performanceInsightsEnabled", - "publiclyAccessible" - ], - "allocatedStorage": 30, - "applyImmediately": false, - "autoMinorVersionUpgrade": true, - "copyTagsToSnapshot": false, - "deleteAutomatedBackups": true, - "engine": "postgres", - "identifier": "postgresdb8a8a6f1", - "instanceClass": "db.t4g.micro", - "monitoringInterval": 0, - "dbName": "airflow", - "password": "tuFp574p9Arw58gu", - "performanceInsightsEnabled": false, - "publiclyAccessible": false, - "skipFinalSnapshot": true, - "username": "airflow" - }, - "oldInputs": { - "__defaults": [ - "applyImmediately", - "autoMinorVersionUpgrade", - "copyTagsToSnapshot", - "deleteAutomatedBackups", - "identifier", - "monitoringInterval", - "performanceInsightsEnabled", - "publiclyAccessible" - ], - "allocatedStorage": 30, - "applyImmediately": false, - "autoMinorVersionUpgrade": true, - "copyTagsToSnapshot": false, - "deleteAutomatedBackups": true, - "engine": "postgres", - "identifier": "postgresdb8a8a6f1", - "instanceClass": "db.t4g.micro", - "monitoringInterval": 0, - "name": "airflow", - "password": "tuFp574p9Arw58gu", - "performanceInsightsEnabled": false, - "publiclyAccessible": false, - "skipFinalSnapshot": true, - "username": "airflow" - } - }, - "response": { - "stables": "*", - "changes": "*", - "hasDetailedDiff": true - }, - "metadata": { - "kind": "resource", - "mode": "client", - "name": "aws" - } - }, - { - "method": "/pulumirpc.ResourceProvider/Diff", - "request": { - "id": "rds2f5ed54", - "urn": "urn:pulumi:exp2::secret-random-yaml::aws:rds/instance:Instance::rds", - "olds": { - "__meta": "{\"e2bfb730-ecaa-11e6-8f88-34363bc7c4c0\":{\"create\":2400000000000,\"delete\":3600000000000,\"update\":4800000000000},\"schema_version\":\"1\"}", - "address": "rds2f5ed54.c1xxca33i6kr.us-east-2.rds.amazonaws.com", - "allocatedStorage": 16, - "arn": "arn:aws:rds:us-east-2:616138583583:db:rds2f5ed54", - "autoMinorVersionUpgrade": true, - "availabilityZone": "us-east-2c", - "backupRetentionPeriod": 0, - "backupWindow": "07:34-08:04", - "caCertIdentifier": "rds-ca-2019", - "copyTagsToSnapshot": false, - "dbSubnetGroupName": "default", - "deleteAutomatedBackups": true, - "deletionProtection": false, - "domain": "", - "domainIamRoleName": "", - "enabledCloudwatchLogsExports": [], - "endpoint": "rds2f5ed54.c1xxca33i6kr.us-east-2.rds.amazonaws.com:3306", - "engine": "mysql", - "engineVersion": "8.0.33", - "hostedZoneId": "Z2XHWR1WZ565X2", - "iamDatabaseAuthenticationEnabled": false, - "id": "rds2f5ed54", - "identifier": "rds2f5ed54", - "instanceClass": "db.t3.micro", - "iops": 0, - "kmsKeyId": "", - "latestRestorableTime": "0001-01-01T00:00:00Z", - "licenseModel": "general-public-license", - "maintenanceWindow": "sun:03:59-sun:04:29", - "maxAllocatedStorage": 0, - "monitoringInterval": 0, - "monitoringRoleArn": "", - "multiAz": false, - "name": "name", - "optionGroupName": "default:mysql-8-0", - "parameterGroupName": "default.mysql8.0", - "password": "FOO-BAR-FIZZ1!2", - "performanceInsightsEnabled": false, - "performanceInsightsKmsKeyId": "", - "performanceInsightsRetentionPeriod": 0, - "port": 3306, - "publiclyAccessible": false, - "replicas": [], - "replicateSourceDb": "", - "resourceId": "db-N57SF65OZ5KO3TPK73R7DQMLZA", - "securityGroupNames": [], - "skipFinalSnapshot": true, - "status": "available", - "storageEncrypted": false, - "storageType": "gp2", - "tags": { - "some": "change" - }, - "timezone": "", - "username": "root", - "vpcSecurityGroupIds": [ - "sg-1928d262" - ] - }, - "news": { - "__defaults": [ - "applyImmediately", - "autoMinorVersionUpgrade", - "copyTagsToSnapshot", - "deleteAutomatedBackups", - "identifier", - "monitoringInterval", - "performanceInsightsEnabled", - "publiclyAccessible" - ], - "allocatedStorage": 16, - "applyImmediately": false, - "autoMinorVersionUpgrade": true, - "copyTagsToSnapshot": false, - "dbName": "name", - "deleteAutomatedBackups": true, - "engine": "mysql", - "identifier": "rds2f5ed54", - "instanceClass": "db.t3.micro", - "monitoringInterval": 0, - "password": "FOO-BAR-FIZZ1!2", - "performanceInsightsEnabled": false, - "publiclyAccessible": false, - "skipFinalSnapshot": true, - "tags": { - "__defaults": [], - "some": "change" - }, - "username": "root" - }, - "oldInputs": { - "__defaults": [ - "applyImmediately", - "autoMinorVersionUpgrade", - "copyTagsToSnapshot", - "deleteAutomatedBackups", - "identifier", - "monitoringInterval", - "performanceInsightsEnabled", - "publiclyAccessible" - ], - "allocatedStorage": 16, - "applyImmediately": false, - "autoMinorVersionUpgrade": true, - "copyTagsToSnapshot": false, - "deleteAutomatedBackups": true, - "engine": "mysql", - "identifier": "rds2f5ed54", - "instanceClass": "db.t3.micro", - "monitoringInterval": 0, - "name": "name", - "password": "FOO-BAR-FIZZ1!2", - "performanceInsightsEnabled": false, - "publiclyAccessible": false, - "skipFinalSnapshot": true, - "tags": { - "__defaults": [], - "some": "change" - }, - "username": "root" - } - }, - "response": { - "stables": "*", - "changes": "*", - "hasDetailedDiff": true - }, - "metadata": { - "kind": "resource", - "mode": "client", - "name": "aws" - } - } -]`) + case1 := `[{ + "method": "/pulumirpc.ResourceProvider/Diff", + "request": { + "id": "postgresdb8a8a6f1", + "urn": "urn:pulumi:dev::ts::aws:rds/instance:Instance::postgresdb", + "olds": { + "__meta": "{\"e2bfb730-ecaa-11e6-8f88-34363bc7c4c0\":{\"create\":2400000000000,\"delete\":3600000000000,\"update\":4800000000000},\"schema_version\":\"1\"}", + "address": "postgresdb8a8a6f1.chuqccm8uxqx.us-west-2.rds.amazonaws.com", + "allocatedStorage": 30, + "applyImmediately": false, + "arn": "arn:aws:rds:us-west-2:616138583583:db:postgresdb8a8a6f1", + "autoMinorVersionUpgrade": true, + "availabilityZone": "us-west-2d", + "backupRetentionPeriod": 0, + "backupWindow": "06:15-06:45", + "caCertIdentifier": "rds-ca-2019", + "characterSetName": "", + "copyTagsToSnapshot": false, + "customIamInstanceProfile": "", + "customerOwnedIpEnabled": false, + "dbName": "airflow", + "dbSubnetGroupName": "default", + "deleteAutomatedBackups": true, + "deletionProtection": false, + "domain": "", + "domainIamRoleName": "", + "enabledCloudwatchLogsExports": [], + "endpoint": "postgresdb8a8a6f1.chuqccm8uxqx.us-west-2.rds.amazonaws.com:5432", + "engine": "postgres", + "engineVersion": "15.3", + "engineVersionActual": "15.3", + "hostedZoneId": "Z1PVIF0B656C1W", + "iamDatabaseAuthenticationEnabled": false, + "id": "postgresdb8a8a6f1", + "identifier": "postgresdb8a8a6f1", + "identifierPrefix": "", + "instanceClass": "db.t4g.micro", + "iops": 0, + "kmsKeyId": "", + "latestRestorableTime": "", + "licenseModel": "postgresql-license", + "listenerEndpoints": [], + "maintenanceWindow": "sun:07:16-sun:07:46", + "masterUserSecrets": [], + "maxAllocatedStorage": 0, + "monitoringInterval": 0, + "monitoringRoleArn": "", + "multiAz": false, + "name": "airflow", + "ncharCharacterSetName": "", + "networkType": "IPV4", + "optionGroupName": "default:postgres-15", + "parameterGroupName": "default.postgres15", + "password": "tuFp574p9Arw58gu", + "performanceInsightsEnabled": false, + "performanceInsightsKmsKeyId": "", + "performanceInsightsRetentionPeriod": 0, + "port": 5432, + "publiclyAccessible": false, + "replicaMode": "", + "replicas": [], + "replicateSourceDb": "", + "resourceId": "db-DUPUZANEFBXYECMTI2B5RZPTOE", + "securityGroupNames": [], + "skipFinalSnapshot": true, + "status": "available", + "storageEncrypted": false, + "storageThroughput": 0, + "storageType": "gp2", + "tags": {}, + "tagsAll": {}, + "timezone": "", + "username": "airflow", + "vpcSecurityGroupIds": [ + "sg-4d436f12" + ] + }, + "news": { + "__defaults": [ + "applyImmediately", + "autoMinorVersionUpgrade", + "copyTagsToSnapshot", + "deleteAutomatedBackups", + "identifier", + "monitoringInterval", + "performanceInsightsEnabled", + "publiclyAccessible" + ], + "allocatedStorage": 30, + "applyImmediately": false, + "autoMinorVersionUpgrade": true, + "copyTagsToSnapshot": false, + "deleteAutomatedBackups": true, + "engine": "postgres", + "identifier": "postgresdb8a8a6f1", + "instanceClass": "db.t4g.micro", + "monitoringInterval": 0, + "dbName": "airflow", + "password": "tuFp574p9Arw58gu", + "performanceInsightsEnabled": false, + "publiclyAccessible": false, + "skipFinalSnapshot": true, + "username": "airflow" + }, + "oldInputs": { + "__defaults": [ + "applyImmediately", + "autoMinorVersionUpgrade", + "copyTagsToSnapshot", + "deleteAutomatedBackups", + "identifier", + "monitoringInterval", + "performanceInsightsEnabled", + "publiclyAccessible" + ], + "allocatedStorage": 30, + "applyImmediately": false, + "autoMinorVersionUpgrade": true, + "copyTagsToSnapshot": false, + "deleteAutomatedBackups": true, + "engine": "postgres", + "identifier": "postgresdb8a8a6f1", + "instanceClass": "db.t4g.micro", + "monitoringInterval": 0, + "name": "airflow", + "password": "tuFp574p9Arw58gu", + "performanceInsightsEnabled": false, + "publiclyAccessible": false, + "skipFinalSnapshot": true, + "username": "airflow" + } + }, + "response": { + "stables": "*", + "changes": "*", + "hasDetailedDiff": true + } + }]` + + case2 := `[{ + "method": "/pulumirpc.ResourceProvider/Diff", + "request": { + "id": "rds2f5ed54", + "urn": "urn:pulumi:exp2::secret-random-yaml::aws:rds/instance:Instance::rds", + "olds": { + "__meta": "{\"e2bfb730-ecaa-11e6-8f88-34363bc7c4c0\":{\"create\":2400000000000,\"delete\":3600000000000,\"update\":4800000000000},\"schema_version\":\"1\"}", + "address": "rds2f5ed54.c1xxca33i6kr.us-east-2.rds.amazonaws.com", + "allocatedStorage": 16, + "arn": "arn:aws:rds:us-east-2:616138583583:db:rds2f5ed54", + "autoMinorVersionUpgrade": true, + "availabilityZone": "us-east-2c", + "backupRetentionPeriod": 0, + "backupWindow": "07:34-08:04", + "caCertIdentifier": "rds-ca-2019", + "copyTagsToSnapshot": false, + "dbSubnetGroupName": "default", + "deleteAutomatedBackups": true, + "deletionProtection": false, + "domain": "", + "domainIamRoleName": "", + "enabledCloudwatchLogsExports": [], + "endpoint": "rds2f5ed54.c1xxca33i6kr.us-east-2.rds.amazonaws.com:3306", + "engine": "mysql", + "engineVersion": "8.0.33", + "hostedZoneId": "Z2XHWR1WZ565X2", + "iamDatabaseAuthenticationEnabled": false, + "id": "rds2f5ed54", + "identifier": "rds2f5ed54", + "instanceClass": "db.t3.micro", + "iops": 0, + "kmsKeyId": "", + "latestRestorableTime": "0001-01-01T00:00:00Z", + "licenseModel": "general-public-license", + "maintenanceWindow": "sun:03:59-sun:04:29", + "maxAllocatedStorage": 0, + "monitoringInterval": 0, + "monitoringRoleArn": "", + "multiAz": false, + "name": "name", + "optionGroupName": "default:mysql-8-0", + "parameterGroupName": "default.mysql8.0", + "password": "FOO-BAR-FIZZ1!2", + "performanceInsightsEnabled": false, + "performanceInsightsKmsKeyId": "", + "performanceInsightsRetentionPeriod": 0, + "port": 3306, + "publiclyAccessible": false, + "replicas": [], + "replicateSourceDb": "", + "resourceId": "db-N57SF65OZ5KO3TPK73R7DQMLZA", + "securityGroupNames": [], + "skipFinalSnapshot": true, + "status": "available", + "storageEncrypted": false, + "storageType": "gp2", + "tags": { + "some": "change" + }, + "timezone": "", + "username": "root", + "vpcSecurityGroupIds": [ + "sg-1928d262" + ] + }, + "news": { + "__defaults": [ + "applyImmediately", + "autoMinorVersionUpgrade", + "copyTagsToSnapshot", + "deleteAutomatedBackups", + "identifier", + "monitoringInterval", + "performanceInsightsEnabled", + "publiclyAccessible" + ], + "allocatedStorage": 16, + "applyImmediately": false, + "autoMinorVersionUpgrade": true, + "copyTagsToSnapshot": false, + "dbName": "name", + "deleteAutomatedBackups": true, + "engine": "mysql", + "identifier": "rds2f5ed54", + "instanceClass": "db.t3.micro", + "monitoringInterval": 0, + "password": "FOO-BAR-FIZZ1!2", + "performanceInsightsEnabled": false, + "publiclyAccessible": false, + "skipFinalSnapshot": true, + "tags": { + "__defaults": [], + "some": "change" + }, + "username": "root" + }, + "oldInputs": { + "__defaults": [ + "applyImmediately", + "autoMinorVersionUpgrade", + "copyTagsToSnapshot", + "deleteAutomatedBackups", + "identifier", + "monitoringInterval", + "performanceInsightsEnabled", + "publiclyAccessible" + ], + "allocatedStorage": 16, + "applyImmediately": false, + "autoMinorVersionUpgrade": true, + "copyTagsToSnapshot": false, + "deleteAutomatedBackups": true, + "engine": "mysql", + "identifier": "rds2f5ed54", + "instanceClass": "db.t3.micro", + "monitoringInterval": 0, + "name": "name", + "password": "FOO-BAR-FIZZ1!2", + "performanceInsightsEnabled": false, + "publiclyAccessible": false, + "skipFinalSnapshot": true, + "tags": { + "__defaults": [], + "some": "change" + }, + "username": "root" + } + }, + "response": { + "stables": "*", + "changes": "*", + "hasDetailedDiff": true + } + } + ]` + + // Like case2 but permits detailedDiff. + case2a := `[{ + "method": "/pulumirpc.ResourceProvider/Diff", + "request": { + "id": "rds2f5ed54", + "urn": "urn:pulumi:exp2::secret-random-yaml::aws:rds/instance:Instance::rds", + "olds": { + "__meta": "{\"e2bfb730-ecaa-11e6-8f88-34363bc7c4c0\":{\"create\":2400000000000,\"delete\":3600000000000,\"update\":4800000000000},\"schema_version\":\"1\"}", + "address": "rds2f5ed54.c1xxca33i6kr.us-east-2.rds.amazonaws.com", + "allocatedStorage": 16, + "arn": "arn:aws:rds:us-east-2:616138583583:db:rds2f5ed54", + "autoMinorVersionUpgrade": true, + "availabilityZone": "us-east-2c", + "backupRetentionPeriod": 0, + "backupWindow": "07:34-08:04", + "caCertIdentifier": "rds-ca-2019", + "copyTagsToSnapshot": false, + "dbSubnetGroupName": "default", + "deleteAutomatedBackups": true, + "deletionProtection": false, + "domain": "", + "domainIamRoleName": "", + "enabledCloudwatchLogsExports": [], + "endpoint": "rds2f5ed54.c1xxca33i6kr.us-east-2.rds.amazonaws.com:3306", + "engine": "mysql", + "engineVersion": "8.0.33", + "hostedZoneId": "Z2XHWR1WZ565X2", + "iamDatabaseAuthenticationEnabled": false, + "id": "rds2f5ed54", + "identifier": "rds2f5ed54", + "instanceClass": "db.t3.micro", + "iops": 0, + "kmsKeyId": "", + "latestRestorableTime": "0001-01-01T00:00:00Z", + "licenseModel": "general-public-license", + "maintenanceWindow": "sun:03:59-sun:04:29", + "maxAllocatedStorage": 0, + "monitoringInterval": 0, + "monitoringRoleArn": "", + "multiAz": false, + "name": "name", + "optionGroupName": "default:mysql-8-0", + "parameterGroupName": "default.mysql8.0", + "password": "FOO-BAR-FIZZ1!2", + "performanceInsightsEnabled": false, + "performanceInsightsKmsKeyId": "", + "performanceInsightsRetentionPeriod": 0, + "port": 3306, + "publiclyAccessible": false, + "replicas": [], + "replicateSourceDb": "", + "resourceId": "db-N57SF65OZ5KO3TPK73R7DQMLZA", + "securityGroupNames": [], + "skipFinalSnapshot": true, + "status": "available", + "storageEncrypted": false, + "storageType": "gp2", + "tags": { + "some": "change" + }, + "timezone": "", + "username": "root", + "vpcSecurityGroupIds": [ + "sg-1928d262" + ] + }, + "news": { + "__defaults": [ + "applyImmediately", + "autoMinorVersionUpgrade", + "copyTagsToSnapshot", + "deleteAutomatedBackups", + "identifier", + "monitoringInterval", + "performanceInsightsEnabled", + "publiclyAccessible" + ], + "allocatedStorage": 16, + "applyImmediately": false, + "autoMinorVersionUpgrade": true, + "copyTagsToSnapshot": false, + "dbName": "name", + "deleteAutomatedBackups": true, + "engine": "mysql", + "identifier": "rds2f5ed54", + "instanceClass": "db.t3.micro", + "monitoringInterval": 0, + "password": "FOO-BAR-FIZZ1!2", + "performanceInsightsEnabled": false, + "publiclyAccessible": false, + "skipFinalSnapshot": true, + "tags": { + "__defaults": [], + "some": "change" + }, + "username": "root" + }, + "oldInputs": { + "__defaults": [ + "applyImmediately", + "autoMinorVersionUpgrade", + "copyTagsToSnapshot", + "deleteAutomatedBackups", + "identifier", + "monitoringInterval", + "performanceInsightsEnabled", + "publiclyAccessible" + ], + "allocatedStorage": 16, + "applyImmediately": false, + "autoMinorVersionUpgrade": true, + "copyTagsToSnapshot": false, + "deleteAutomatedBackups": true, + "engine": "mysql", + "identifier": "rds2f5ed54", + "instanceClass": "db.t3.micro", + "monitoringInterval": 0, + "name": "name", + "password": "FOO-BAR-FIZZ1!2", + "performanceInsightsEnabled": false, + "publiclyAccessible": false, + "skipFinalSnapshot": true, + "tags": { + "__defaults": [], + "some": "change" + }, + "username": "root" + } + }, + "response": { + "diffs": "*", + "stables": "*", + "changes": "*", + "hasDetailedDiff": true, + "detailedDiff": "*" + } + } + ]` + + t.Run("case1", func(t *testing.T) { replay(t, case1) }) + t.Run("case2", func(t *testing.T) { replay(t, case2) }) + t.Setenv("PULUMI_ENABLE_PLAN_RESOURCE_CHANGE", "true") + t.Run("case1-plan-resource-change", func(t *testing.T) { replay(t, case1) }) + t.Run("case2-plan-resource-change", func(t *testing.T) { replay(t, case2a) }) } func TestRegressUnknownTags(t *testing.T) { diff --git a/provider/resources.go b/provider/resources.go index 2906dc3d7fe..2764be046f9 100644 --- a/provider/resources.go +++ b/provider/resources.go @@ -3095,6 +3095,7 @@ func ProviderFromMeta(metaInfo *tfbridge.MetadataInfo) *tfbridge.ProviderInfo { }, TransformFromState: func(ctx context.Context, state resource.PropertyMap) (resource.PropertyMap, error) { if _, ok := state["dbName"]; ok { + delete(state, "name") return state, nil } name, ok := state["name"]