Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(infra): final tweaks for prod pulumi updates, removing pulumi migration code #385

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 37 additions & 53 deletions infra/prod/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,9 @@ const privateSubnetSecurityGroup = new aws.ec2.SecurityGroup(
//////////////////////////////////////////////////////////////
// Set up RDS instance
//////////////////////////////////////////////////////////////
let dbSubnetGroup = new aws.rds.SubnetGroup(
`scorer-db-subnet`,
{
subnetIds: vpcPrivateSubnetIds,
},
{
// TODO delete this once the pulumi library update
// is released and running
replaceOnChanges: ["*"],
}
);
let dbSubnetGroup = new aws.rds.SubnetGroup(`scorer-db-subnet`, {
subnetIds: vpcPrivateSubnetIds,
});

const db_secgrp = new aws.ec2.SecurityGroup(`scorer-db-secgrp`, {
description: "Security Group for DB",
Expand Down Expand Up @@ -145,17 +137,15 @@ const postgresql = new aws.rds.Instance(
deletionProtection: true,
backupRetentionPeriod: 5,
performanceInsightsEnabled: true,
// TODO delete this once the pulumi library update
// is released and running
applyImmediately: true,
},
{ protect: true }
);

const readreplica0 = new aws.rds.Instance(
`scorer-db-read-0`,
"scorer-db-read-00679bbe",
{
allocatedStorage: 20,
identifier: "scorer-db-read-00679bbe",
allocatedStorage: 130,
maxAllocatedStorage: 500,
instanceClass: "db.t3.xlarge",
skipFinalSnapshot: true,
Expand All @@ -164,9 +154,6 @@ const readreplica0 = new aws.rds.Instance(
// backupRetentionPeriod: 5, - this is not supported for read replicas running PostgreSQL versions lower than 14
replicateSourceDb: postgresql.id,
performanceInsightsEnabled: true,
// TODO delete this once the pulumi library update
// is released and running
applyImmediately: true,
},
{ protect: true }
);
Expand All @@ -189,11 +176,6 @@ const redisSubnetGroup = new aws.elasticache.SubnetGroup(
"scorer-redis-subnet",
{
subnetIds: vpcPrivateSubnetIds,
},
{
// TODO delete this once the pulumi library update
// is released and running
replaceOnChanges: ["*"],
}
);

Expand Down Expand Up @@ -616,8 +598,8 @@ const celery1 = new awsx.ecs.FargateService("scorer-bkgrnd-worker-registry", {
executionRole: {
roleArn: workerRole.arn,
},
cpu: "16vCPU",
memory: "32GB",
cpu: "16384",
memory: "32768",
containers: {
worker1: {
name: "worker1",
Expand Down Expand Up @@ -982,7 +964,7 @@ export const dockrRunCmd = pulumi.secret(
// Redash instance
///////////////////////

const redashDbSecgrp = new aws.ec2.SecurityGroup(`redashDbSecgrp`, {
const redashDbSecgrp = new aws.ec2.SecurityGroup(`redashDbSecgrp-fe96c4b`, {
description: "Security Group for DB",
vpcId: vpcID,
ingress: [
Expand All @@ -1001,6 +983,7 @@ const redashDbSecgrp = new aws.ec2.SecurityGroup(`redashDbSecgrp`, {
cidrBlocks: ["0.0.0.0/0"],
},
],
name: "redashDbSecgrp-fe96c4b",
});

let redashDbUsername = `${process.env["REDASH_DB_USER"]}`;
Expand All @@ -1010,8 +993,9 @@ let redashSecretKey = pulumi.secret(`${process.env["REDASH_SECRET_KEY"]}`);

// Create an RDS instance
const redashDb = new aws.rds.Instance(
"redash-db",
"redash-db-0",
{
identifier: "redash-db-0",
allocatedStorage: 20,
maxAllocatedStorage: 20,
engine: "postgres",
Expand All @@ -1025,9 +1009,6 @@ const redashDb = new aws.rds.Instance(
vpcSecurityGroupIds: [redashDbSecgrp.id],
backupRetentionPeriod: 5,
performanceInsightsEnabled: true,
// TODO delete this once the pulumi library update
// is released and running
applyImmediately: true,
},
{ protect: true }
);
Expand Down Expand Up @@ -1076,28 +1057,31 @@ const redashSecurityGroup = new aws.ec2.SecurityGroup(
}
);

const redashInitScript = redashDbUrl.apply((url) => {
return redashSecretKey.apply((secretKey) => {
return `#!/bin/bash
echo "Setting environment variables..."
export POSTGRES_PASSWORD="${redashDbPassword}"
export REDASH_DATABASE_URL="${url}"
export REDASH_SECRET_KEY="${secretKey}"

echo "Cloning passport-redash repository..."
git clone https://github.com/gitcoinco/passport-redash.git

echo "Changing directory and setting permissions..."
cd passport-redash
sudo chmod +x ./setup.sh
./setup.sh

cd data

sudo docker-compose up -d
`;
});
});
const redashInitScript = redashDbUrl.apply((url) =>
redashDbPassword.apply((password) =>
redashSecretKey.apply(
(secretKey) =>
`#!/bin/bash
echo "Setting environment variables..."
export POSTGRES_PASSWORD="${password}"
export REDASH_DATABASE_URL="${url}"
export REDASH_SECRET_KEY="${secretKey}"

echo "Cloning passport-redash repository..."
git clone https://github.com/gitcoinco/passport-redash.git

echo "Changing directory and setting permissions..."
cd passport-redash
sudo chmod +x ./setup.sh
./setup.sh

cd data

sudo docker-compose up -d
`
)
)
);

const redashinstance = new aws.ec2.Instance("redashinstance", {
ami: ubuntu.then((ubuntu: { id: any }) => ubuntu.id),
Expand Down
22 changes: 3 additions & 19 deletions infra/review/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,9 @@ const privateSubnetSecurityGroup = new aws.ec2.SecurityGroup(
//////////////////////////////////////////////////////////////
// Set up RDS instance
//////////////////////////////////////////////////////////////
let dbSubnetGroup = new aws.rds.SubnetGroup(
`scorer-db-subnet`,
{
subnetIds: vpcPrivateSubnetIds,
},
{
// TODO delete this once the pulumi library update
// is released and running
replaceOnChanges: ["*"],
}
);
let dbSubnetGroup = new aws.rds.SubnetGroup(`scorer-db-subnet`, {
subnetIds: vpcPrivateSubnetIds,
});

const db_secgrp = new aws.ec2.SecurityGroup(`scorer-db-secgrp`, {
description: "Security Group for DB",
Expand Down Expand Up @@ -136,9 +128,6 @@ const postgresql = new aws.rds.Instance(
dbSubnetGroupName: dbSubnetGroup.id,
vpcSecurityGroupIds: [db_secgrp.id],
backupRetentionPeriod: 5,
// TODO delete this once the pulumi library update
// is released and running
applyImmediately: true,
},
{ protect: true }
);
Expand All @@ -158,11 +147,6 @@ const redisSubnetGroup = new aws.elasticache.SubnetGroup(
"scorer-redis-subnet",
{
subnetIds: vpcPrivateSubnetIds,
},
{
// TODO delete this once the pulumi library update
// is released and running
replaceOnChanges: ["*"],
}
);

Expand Down
25 changes: 3 additions & 22 deletions infra/staging/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,9 @@ const privateSubnetSecurityGroup = new aws.ec2.SecurityGroup(
//////////////////////////////////////////////////////////////
// Set up RDS instance
//////////////////////////////////////////////////////////////
let dbSubnetGroup = new aws.rds.SubnetGroup(
`scorer-db-subnet`,
{
subnetIds: vpcPrivateSubnetIds,
},
{
// TODO delete this once the pulumi library update
// is released and running
replaceOnChanges: ["*"],
}
);
let dbSubnetGroup = new aws.rds.SubnetGroup(`scorer-db-subnet`, {
subnetIds: vpcPrivateSubnetIds,
});

const db_secgrp = new aws.ec2.SecurityGroup(`scorer-db-secgrp`, {
description: "Security Group for DB",
Expand Down Expand Up @@ -144,9 +136,6 @@ const postgresql = new aws.rds.Instance(
vpcSecurityGroupIds: [db_secgrp.id],
backupRetentionPeriod: 5,
performanceInsightsEnabled: true,
// TODO delete this once the pulumi library update
// is released and running
applyImmediately: true,
},
{ protect: true }
);
Expand All @@ -166,11 +155,6 @@ const redisSubnetGroup = new aws.elasticache.SubnetGroup(
"scorer-redis-subnet",
{
subnetIds: vpcPrivateSubnetIds,
},
{
// TODO delete this once the pulumi library update
// is released and running
replaceOnChanges: ["*"],
}
);

Expand Down Expand Up @@ -951,9 +935,6 @@ const redashDb = new aws.rds.Instance(
vpcSecurityGroupIds: [redashDbSecgrp.id],
backupRetentionPeriod: 5,
performanceInsightsEnabled: true,
// TODO delete this once the pulumi library update
// is released and running
applyImmediately: true,
},
{ protect: true }
);
Expand Down