https://pulumi.com logo
#aws
Title
# aws
g

gifted-yak-28427

12/16/2020, 3:39 PM
Hey guys. When deploying a RDS instance with both
snapshot_identifier
and
username
defined the username does not get set to what I've defined. It always stays at what was originally in the snapshot. The problem is this results in a replacement loop as pulumi always detects a difference. Anyone know if I'm missing something or are these two not meant to be used together?
b

billowy-army-68599

12/16/2020, 4:19 PM
can you share a code snippet?
g

gifted-yak-28427

12/16/2020, 4:27 PM
Sure. The instance looks like this:
Copy code
kv_db_subnet_group = aws.rds.SubnetGroup(env_name,
    subnet_ids=[
                kv_subnets[env_name + '-db-a']['id'],
                kv_subnets[env_name + '-db-b']['id'],
                kv_subnets[env_name + '-db-c']['id']
    ],
    tags  = {**default_tags,
            **{'Name': env_name + '-postgres'}
            } 
)

kv_mysql_password = random.RandomPassword(env_name + '-mysql-password',
    length  = 30,
    special = False
)


kv_mysql_paramaters = aws.rds.ParameterGroup(env_name + '-mysql',
    family      = "mysql5.6",
    parameters  = [
        aws.rds.ParameterGroupParameterArgs(
            name  = "character_set_database",
            value = "utf8"
        ),
        aws.rds.ParameterGroupParameterArgs(
            name  = "innodb_log_file_size",
            value = "536870912",
            apply_method = "pending-reboot"
        ),
        aws.rds.ParameterGroupParameterArgs(
            name  = "join_buffer_size",
            value = "134217728"
        ),
        aws.rds.ParameterGroupParameterArgs(
            name  = "binlog_format",
            value = "ROW"
        )                                                                   
    ]
)

mysql_vars = config.require_object('mysql')
kv_mysql = aws.rds.Instance(env_name + '-mysql-',
    snapshot_identifier    = config.require('mysql_snapshot'),
    engine                 = mysql_vars['engine'],
    engine_version         = mysql_vars['version'],
    instance_class         = mysql_vars['instance_size'],
    allocated_storage      = mysql_vars['storage'],
    skip_final_snapshot    = mysql_vars['skip_snapshot'],
    max_allocated_storage  = mysql_vars['max_storage'],
    storage_type           = mysql_vars['storage_type'],
    storage_encrypted      = True,
    copy_tags_to_snapshot  = True,
    db_subnet_group_name   = kv_db_subnet_group.name,
    availability_zone      = region + "a",
    multi_az               = mysql_vars['multi_az'],
    vpc_security_group_ids = [sg_list[env_name + '-db']['id']],
    parameter_group_name   = kv_mysql_paramaters.name,
    username               = "rds_admin",
    password               = kv_mysql_password.result,
    performance_insights_enabled = mysql_vars['perf_insights'],
    tags  = {**default_tags,
            **{'Name': env_name + '-rds-mysql'}
            }
)
the mysql config looks like this:
Copy code
data:mysql_snapshot: rds-mysql-qa-manual
data:mysql:
  instance_size: db.t3.medium
  storage: 110
  max_storage: 200
  version: "5.6.40"
  engine: "mysql"
  storage_type: gp2
  perf_insights: False
  multi_az: False
  skip_snapshot: True