Beispiel #1
0
 def _get_mysql_provider(self, db_uid):
     """Returns a MySQL Pulumi provider specific to the database referenced by its UID."""
     db = self.model.aws.databases[db_uid]
     return mysql.Provider(
         self._res_name(db_uid),
         endpoint=f"{db.endpoint.address}:{db.endpoint.port}",
         proxy=self.model.system.proxy,
         username=db.master_username,
         password=pulumi.Output.secret(db.master_password))
Beispiel #2
0
# An RDS instnace is created to hold our MySQL database
mysql_rds_server = aws.rds.Instance("mysql-server",
    engine="mysql",
    username=sql_admin_name,
    password=sql_admin_password,
    instance_class="db.t2.micro",
    allocated_storage=20,
    skip_final_snapshot=True,
    publicly_accessible=True,
    db_subnet_group_name=app_database_subnetgroup.id,
    vpc_security_group_ids=[app_security_group.id])

# Creating a Pulumi MySQL provider to allow us to interact with the RDS instance
mysql_provider = mysql.Provider("mysql-provider",
    endpoint=mysql_rds_server.endpoint,
    username=sql_admin_name,
    password=sql_admin_password)

# Initializing a basic database on the RDS instance
mysql_database = mysql.Database("mysql-database",
    name="votes",
    opts=pulumi.ResourceOptions(provider=mysql_provider))

# Creating a user which will be used to manage MySQL tables
mysql_user = mysql.User("mysql-standard-user",
    user=sql_user_name,
    host="%", # "%" indicates that the connection is allowed to come from anywhere
    plaintext_password=sql_user_password,
    opts=pulumi.ResourceOptions(provider=mysql_provider))

# The user only needs the "SELECT", "UPDATE", "INSERT", and "DELETE" permissions to function