Hi I created an aurora cluster for mysql and 2 ins...
# general
s
Hi I created an aurora cluster for mysql and 2 instances corresponding to it. The first pass created it successfully, however anytime I do a subsequent pulumi up without any code changes, the cluster and the instances have a replace status. Am I doing anything wrong here?
Copy code
const defaultCluster = new aws.rds.Cluster(`${stack}-aurora-mysql-cluster`, {
    availabilityZones: auroraConfig.instances.map(x=> x.zoneName),
    applyImmediately: auroraConfig.applyImmediately,
    backupRetentionPeriod: auroraConfig.backupRetentionPeriod,
    clusterIdentifier: `aurora-cluster-${stack}`,
    databaseName: auroraConfig.database,
    vpcSecurityGroupIds: [sg.id],
    dbSubnetGroupName: subnetGroup.name,
    engine: "aurora-mysql",
    engineVersion: "5.7.mysql_aurora.2.03.2",
    preferredBackupWindow: "07:00-09:00",
    port: 3306,
    masterUsername: "admin",
    masterPassword: dbPassword.result,
    tags: {
        Environment: stack
    },
});

let clusterInstances: aws.rds.ClusterInstance[] = [];

for (const range = {value: 0}; range.value < auroraConfig.instances.length; range.value++) {
    clusterInstances.push(new aws.rds.ClusterInstance(`${stack}-clusterInstances-${range.value}`, {
        identifier: `aurora-cluster-${stack}-instance-${range.value}`,
        clusterIdentifier: defaultCluster.id,
        instanceClass: auroraConfig.instanceType,
        engine: "aurora-mysql",
        engineVersion: defaultCluster.engineVersion,
        tags: {
            Environment: stack
        },
    }));
};
The change seem to be on ~availability on thecluster
b
Can you show the diff?
👍 1
s
Copy code
test-aurora-mysql-cluster (aws:rds:Cluster)
-- aws:rds/cluster:Cluster (delete-replaced)
    [id=aurora-cluster-test]
    [urn=urn:pulumi:test::infra::aws:rds/cluster:Cluster::test-aurora-mysql-cluster]
    __defaults                 : [
        [0]: "copyTagsToSnapshot"
        [1]: "enableGlobalWriteForwarding"
        [2]: "enableHttpEndpoint"
        [3]: "engineMode"
        [4]: "skipFinalSnapshot"
    ]
    applyImmediately           : true
    availabilityZones          : [
        [0]: "eu-west-1b"
        [1]: "eu-west-1a"
    ]
    backupRetentionPeriod      : 1
    clusterIdentifier          : "aurora-cluster-test"
    copyTagsToSnapshot         : false
    databaseName               : "darkstar"
    dbSubnetGroupName          : "test-db-subnet-group"
    enableGlobalWriteForwarding: false
    enableHttpEndpoint         : false
    engine                     : "aurora-mysql"
    engineMode                 : "provisioned"
    engineVersion              : "5.7.mysql_aurora.2.03.2"
    masterPassword             : [secret]
    masterUsername             : "admin"
    port                       : 3306
    preferredBackupWindow      : "07:00-09:00"
    skipFinalSnapshot          : false
    tags                       : {
        Environment: "test"
    }
    vpcSecurityGroupIds        : [
        [0]: "sg-02dd7c05ab43b5551"
    ]
 
test-clusterInstances-0 (aws:rds:ClusterInstance)
+  aws:rds/clusterInstance:ClusterInstance (create)
    [urn=urn:pulumi:test::infra::aws:rds/clusterInstance:ClusterInstance::test-clusterInstances-0]
    __defaults             : [
        [0]: "autoMinorVersionUpgrade"
        [1]: "copyTagsToSnapshot"
        [2]: "monitoringInterval"
        [3]: "promotionTier"
        [4]: "publiclyAccessible"
    ]
    autoMinorVersionUpgrade: true
    clusterIdentifier      : Output<T>
    copyTagsToSnapshot     : false
    engine                 : "aurora-mysql"
    engineVersion          : "5.7.mysql_aurora.2.03.2"
    identifier             : "aurora-cluster-test-instance-0"
    instanceClass          : "db.t2.small"
    monitoringInterval     : 0
    promotionTier          : 0
    publiclyAccessible     : false
    tags                   : {
        Environment: "test"
        __defaults : []
    }
 
test-clusterInstances-1 (aws:rds:ClusterInstance)
+  aws:rds/clusterInstance:ClusterInstance (create)
    [urn=urn:pulumi:test::infra::aws:rds/clusterInstance:ClusterInstance::test-clusterInstances-1]
    __defaults             : [
        [0]: "autoMinorVersionUpgrade"
        [1]: "copyTagsToSnapshot"
        [2]: "monitoringInterval"
        [3]: "promotionTier"
        [4]: "publiclyAccessible"
    ]
    autoMinorVersionUpgrade: true
    clusterIdentifier      : Output<T>
    copyTagsToSnapshot     : false
    engine                 : "aurora-mysql"
    engineVersion          : "5.7.mysql_aurora.2.03.2"
    identifier             : "aurora-cluster-test-instance-1"
    instanceClass          : "db.t2.small"
    monitoringInterval     : 0
    promotionTier          : 0
    publiclyAccessible     : false
    tags                   : {
        Environment: "test"
        __defaults : []
    }
b
That seems to be because the urn is changing, which indicates the name is changing. You can use an alias to prevent this
s
for the cluster?
I am not sure if I comprehend what field to use for this?
b
Can you show me the undetailed diff, from pulumi up before you hit details
s
I am assuming you are talking about this>
Copy code
Type                        Name                       Plan        Info
     pulumi:pulumi:Stack         infra-test                             
 +-  ├─ aws:rds:Cluster          test-aurora-mysql-cluster  replace     [diff: ~availability
 +-  ├─ aws:rds:ClusterInstance  test-clusterInstances-1    replace     [diff: ~clusterIdent
 +-  └─ aws:rds:ClusterInstance  test-clusterInstances-0    replace     [diff: ~clusterIdent
Fixed it, removed azs from the rds cluster, now its being calculated from the subnet group This was causing the issue
b
❤️