Skip to content

Commit 73e91f2

Browse files
committed
fix: keep old subnet for deployment order reasons
1 parent bee09f5 commit 73e91f2

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

VirtualFinland.UsersAPI.Deployment/Features/PostgresDatabase.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System.Collections.Immutable;
2+
using System.Linq;
13
using Pulumi;
24
using Pulumi.Aws.Rds;
35
using Pulumi.Random;
@@ -13,7 +15,15 @@ public class PostgresDatabase
1315
{
1416
public PostgresDatabase(Config config, StackSetup stackSetup, VpcSetup vpcSetup)
1517
{
16-
var dbSubNetGroup = new Pulumi.Aws.Rds.SubnetGroup("dbsubnets", new()
18+
// @TODO: Remove oldDbSubNetGroup once the the new subnet group is deployed
19+
var infraStackReference = new StackReference($"{Pulumi.Deployment.Instance.OrganizationName}/{config.Require("infraStackReferenceName")}/{stackSetup.Environment}");
20+
var infraStackReferencePrivateSubnetIds = infraStackReference.RequireOutput("PrivateSubnetIds");
21+
var oldDbSubNetGroup = new Pulumi.Aws.Rds.SubnetGroup("dbsubnets", new()
22+
{
23+
SubnetIds = infraStackReferencePrivateSubnetIds.Apply(o => ((ImmutableArray<object>)(o ?? new ImmutableArray<object>())).Select(x => x.ToString())),
24+
});
25+
26+
var dbSubNetGroup = new Pulumi.Aws.Rds.SubnetGroup($"{stackSetup.ProjectName}-dbsubnets-{stackSetup.Environment}", new()
1727
{
1828
SubnetIds = vpcSetup.PrivateSubnetIds,
1929
});
@@ -36,7 +46,7 @@ public PostgresDatabase(Config config, StackSetup stackSetup, VpcSetup vpcSetup)
3646
Username = config.Require("dbAdmin"),
3747
Password = password.Result,
3848
Tags = stackSetup.Tags,
39-
PubliclyAccessible = !stackSetup.IsProductionEnvironment, // DEV: For Production set to FALSE
49+
PubliclyAccessible = false,
4050
SkipFinalSnapshot = !stackSetup.IsProductionEnvironment, // DEV: For production set to FALSE to avoid accidental deletion of the cluster, data safety measure and is the default for AWS.
4151
//SnapshotIdentifier = "" // See README.database.md for more information
4252
});

0 commit comments

Comments
 (0)