sparse-intern-71089
06/02/2020, 7:06 AMdazzling-sundown-39670
06/02/2020, 7:08 AMimport * as pulumi from '@pulumi/pulumi';
import * as mysql from '@pulumi/mysql';
import * as aws from '@pulumi/aws';
import { vpc, sg, pulumiTags } from './vpc';
const config = new pulumi.Config();
const mysqlUser = config.require('mysqlUsername');
const mysqlPassword = config.requireSecret('mysqlPassword');
const instanceClass = config.requireSecret('mysqlInstanceClass');
const subnetGroup = new aws.rds.SubnetGroup('magento2-subnet', {
subnetIds: vpc.privateSubnetIds.then(),
});
const currentRegion = pulumi.output(aws.getRegion());
const defaultCluster = new aws.rds.Cluster('default', {
availabilityZones: [
pulumi.interpolate`${currentRegion.name}a`,
pulumi.interpolate`${currentRegion.name}b`,
],
backupRetentionPeriod: 5,
clusterIdentifier: 'aurora-cluster-demo',
masterUsername: mysqlUser,
masterPassword: mysqlPassword,
preferredBackupWindow: '07:00-09:00',
deletionProtection: false,
vpcSecurityGroupIds: [sg.id],
dbSubnetGroupName: subnetGroup.name,
tags: pulumiTags,
});
const instance = new aws.rds.ClusterInstance(`cluster_instances-1`, {
clusterIdentifier: defaultCluster.id,
identifier: `aurora-cluster-demo-1`,
instanceClass,
publiclyAccessible: true,
tags: pulumiTags,
});
const mysqlProvider = new mysql.Provider('mysql', {
endpoint: defaultCluster.endpoint,
username: defaultCluster.masterUsername,
password: defaultCluster.masterPassword.apply((p) => p!.toString()),
});
const database = new mysql.Database(
'magento2-db',
{
name: 'MAGENTO',
},
{
provider: mysqlProvider,
},
);
const user = new mysql.User(
'magento2',
{
user: 'magento2',
host: '%',
plaintextPassword: 'magento2-secret',
},
{
provider: mysqlProvider,
},
);
new mysql.Grant(
'magento2',
{
user: user.user,
host: user.host.apply((h) => h!.toString()),
database: database.name,
privileges: ['SELECT', 'UPDATE'],
},
{
provider: mysqlProvider,
},
);
gentle-diamond-70147
06/02/2020, 2:57 PMdazzling-sundown-39670
06/02/2020, 4:18 PMmysql:index:Database (magento2-db):
error: Could not connect to server: dial tcp 15.236.150.22:3306: connect: operation timed out
gentle-diamond-70147
06/02/2020, 4:32 PMdazzling-sundown-39670
06/02/2020, 6:33 PMawsx.ec2.SecurityGroupRule.ingress(
'ingress-access',
sg,
new awsx.ec2.AnyIPv4Location(),
new awsx.ec2.AllTcpPorts(),
'allow all ports',
);
but I'm not sure on the routing. I will check if I can find that out. Thank you!No matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.
Powered by