Skip to content

Commit ca7f624

Browse files
committed
chore: wip
1 parent 9b124ab commit ca7f624

File tree

7 files changed

+83
-58
lines changed

7 files changed

+83
-58
lines changed

.stacks/core/cloud/src/cloud/cdn.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
aws_cloudfront_origins as origins,
88
aws_route53 as route53,
99
aws_secretsmanager as secretsmanager,
10-
aws_ssm as ssm,
10+
// aws_ssm as ssm,
1111
aws_route53_targets as targets,
1212
} from 'aws-cdk-lib'
1313
import type { Construct } from 'constructs'

.stacks/core/cloud/src/cloud/file-system.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,3 @@ export class FileSystemStack {
3333
})
3434
}
3535
}
36-
37-
// manageFileSystem() {
38-
// }

.stacks/core/cloud/src/cloud/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { DeploymentStack } from './deployment'
1111
import { JumpBoxStack } from './jump-box'
1212
import { FileSystemStack } from './file-system'
1313
import { NetworkStack } from './network'
14+
import { RedirectsStack } from './redirects'
1415

1516
export class Cloud extends Stack {
1617
constructor(scope: Construct, id: string, props: CloudOptions) {
@@ -54,6 +55,8 @@ export class Cloud extends Stack {
5455
zone: dns.zone,
5556
})
5657

58+
new RedirectsStack(this, props)
59+
5760
new DeploymentStack(this, {
5861
...props,
5962
publicBucket: storage.publicBucket,

.stacks/core/cloud/src/cloud/network.ts

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,41 @@ export class NetworkStack {
1212
constructor(scope: Construct, props: NetworkStackProps) {
1313
this.vpc = new ec2.Vpc(scope, 'Network', {
1414
vpcName: `${props.appName}-${props.appEnv}-vpc`,
15-
// ipAddresses: ec2.IpAddresses.cidr('10.0.0.0/16'),
15+
ipAddresses: ec2.IpAddresses.cidr('10.0.0.0/16'),
1616
maxAzs: 3,
17-
// subnetConfiguration: [
18-
// {
19-
// cidrMask: 19, // Size of the subnet in CIDR notation
20-
// name: `${this.appName}-${appEnv}-public-subnet-1`,
21-
// subnetType: ec2.SubnetType.PUBLIC,
22-
// },
23-
// {
24-
// cidrMask: 19,
25-
// name: `${this.appName}-${appEnv}-public-subnet-2`,
26-
// subnetType: ec2.SubnetType.PUBLIC,
27-
// },
28-
// {
29-
// cidrMask: 19,
30-
// name: `${this.appName}-${appEnv}-private-subnet-1`,
31-
// subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS,
32-
// },
33-
// {
34-
// cidrMask: 19,
35-
// name: `${this.appName}-${appEnv}-private-subnet-2`,
36-
// subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS,
37-
// },
38-
// ],
17+
natGateways: 0,
18+
subnetConfiguration: [
19+
{
20+
cidrMask: 21,
21+
name: `${props.appName}-${props.appEnv}-public-subnet-1`,
22+
subnetType: ec2.SubnetType.PUBLIC,
23+
},
24+
{
25+
cidrMask: 21,
26+
name: `${props.appName}-${props.appEnv}-public-subnet-2`,
27+
subnetType: ec2.SubnetType.PUBLIC,
28+
},
29+
{
30+
cidrMask: 21,
31+
name: `${props.appName}-${props.appEnv}-public-subnet-3`,
32+
subnetType: ec2.SubnetType.PUBLIC,
33+
},
34+
{
35+
cidrMask: 21,
36+
name: `${props.appName}-${props.appEnv}-private-subnet-1`,
37+
subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
38+
},
39+
{
40+
cidrMask: 21,
41+
name: `${props.appName}-${props.appEnv}-private-subnet-2`,
42+
subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
43+
},
44+
{
45+
cidrMask: 21,
46+
name: `${props.appName}-${props.appEnv}-private-subnet-3`,
47+
subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
48+
},
49+
],
3950
})
4051
}
4152
}
Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,45 @@
1-
// for each redirect, create a bucket & redirect it to the APP_URL
2-
// config.dns.redirects?.forEach((redirect) => {
3-
// // TODO: use string-ts function here instead
4-
// const slug = redirect.split('.').map((part, index) => index === 0 ? part : part.charAt(0).toUpperCase() + part.slice(1)).join('') // creates a CamelCase slug from the redirect
5-
// const hostedZone = route53.HostedZone.fromLookup(this, 'HostedZone', { domainName: redirect })
6-
// const redirectBucket = new s3.Bucket(this, `RedirectBucket${slug}`, {
7-
// bucketName: `${redirect}-redirect`,
8-
// websiteRedirect: {
9-
// hostName: this.domain,
10-
// protocol: s3.RedirectProtocol.HTTPS,
11-
// },
12-
// removalPolicy: RemovalPolicy.DESTROY,
13-
// autoDeleteObjects: true,
14-
// })
15-
// new route53.CnameRecord(this, `RedirectRecord${slug}`, {
16-
// zone: hostedZone,
17-
// recordName: 'redirect',
18-
// domainName: redirectBucket.bucketWebsiteDomainName,
19-
// })
20-
// })
1+
/* eslint-disable no-new */
2+
import { config } from '@stacksjs/config'
3+
import { RemovalPolicy, aws_route53 as route53, aws_s3 as s3 } from 'aws-cdk-lib'
4+
import type { Construct } from 'constructs'
5+
import type { NestedCloudProps } from '../types'
216

22-
// TODO: fix this – redirects do not work yet
23-
// config.dns.redirects?.forEach((redirect) => {
24-
// const slug = redirect.split('.').map((part, index) => index === 0 ? part : part.charAt(0).toUpperCase() + part.slice(1)).join('') // creates a CamelCase slug from the redirect
25-
// const hostedZone = route53.HostedZone.fromLookup(this, `RedirectHostedZone${slug}`, { domainName: redirect })
26-
// this.redirectZones.push(hostedZone)
27-
// })
7+
export interface RedirectsStackProps extends NestedCloudProps {
8+
//
9+
}
10+
11+
export class RedirectsStack {
12+
redirectZones: route53.IHostedZone[] = []
13+
14+
constructor(scope: Construct, props: RedirectsStackProps) {
15+
// for each redirect, create a bucket & redirect it to the APP_URL
16+
config.dns.redirects?.forEach((redirect) => {
17+
// TODO: use string-ts function here instead
18+
const slug = redirect.split('.').map((part, index) => index === 0 ? part : part.charAt(0).toUpperCase() + part.slice(1)).join('') // creates a CamelCase slug from the redirect
19+
const hostedZone = route53.HostedZone.fromLookup(scope, 'HostedZone', { domainName: redirect })
20+
21+
const redirectBucket = new s3.Bucket(scope, `RedirectBucket${slug}`, {
22+
bucketName: `${redirect}-redirect`,
23+
websiteRedirect: {
24+
hostName: props.domain,
25+
protocol: s3.RedirectProtocol.HTTPS,
26+
},
27+
removalPolicy: RemovalPolicy.DESTROY,
28+
autoDeleteObjects: true,
29+
})
30+
31+
new route53.CnameRecord(scope, `RedirectRecord${slug}`, {
32+
zone: hostedZone,
33+
recordName: 'redirect',
34+
domainName: redirectBucket.bucketWebsiteDomainName,
35+
})
36+
})
37+
38+
// TODO: fix this – redirects do not work yet
39+
config.dns.redirects?.forEach((redirect) => {
40+
const slug = redirect.split('.').map((part, index) => index === 0 ? part : part.charAt(0).toUpperCase() + part.slice(1)).join('') // creates a CamelCase slug from the redirect
41+
const hostedZone = route53.HostedZone.fromLookup(scope, `RedirectHostedZone${slug}`, { domainName: redirect })
42+
this.redirectZones.push(hostedZone)
43+
})
44+
}
45+
}

.stacks/core/cloud/src/cloud/security.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ export interface StorageStackProps extends NestedCloudProps {
99
zone: route53.IHostedZone
1010
}
1111

12-
// export class SecurityStack extends NestedStack {
1312
export class SecurityStack {
1413
firewall: wafv2.CfnWebACL
1514
kmsKey: kms.Key
1615
certificate: acm.Certificate
1716

1817
constructor(scope: Construct, props: StorageStackProps) {
19-
// super(scope, 'Security', props)
2018
const firewallOptions = config.cloud.firewall
2119

2220
if (!firewallOptions)

.stacks/core/cloud/src/cloud/storage.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import type { aws_kms as kms } from 'aws-cdk-lib'
2-
import { NestedStack, RemovalPolicy, Tags, aws_backup as backup, aws_iam as iam, aws_s3 as s3 } from 'aws-cdk-lib'
2+
import { RemovalPolicy, Tags, aws_backup as backup, aws_iam as iam, aws_s3 as s3 } from 'aws-cdk-lib'
33
import type { Construct } from 'constructs'
44
import type { NestedCloudProps } from '../types'
55

66
export interface StorageStackProps extends NestedCloudProps {
77
kmsKey: kms.Key
88
}
99

10-
// export class StorageStack extends NestedStack {
1110
export class StorageStack {
1211
publicBucket: s3.Bucket
1312
privateBucket: s3.Bucket
@@ -18,7 +17,6 @@ export class StorageStack {
1817
backupRole: iam.Role
1918

2019
constructor(scope: Construct, props: StorageStackProps) {
21-
// super(scope, 'Storage', props)
2220
this.bucketPrefix = `${props.appName}-${props.appEnv}`
2321

2422
this.publicBucket = new s3.Bucket(scope, 'PublicBucket', {

0 commit comments

Comments
 (0)