Skip to content

Commit aa57f4f

Browse files
AndresArconesColduck
authored and
Colduck
committed
Reduced to 50% the costs of AWS
Reduced the cost of the AWS bill by only using 1 hosted zone instead of 2. The cost is reduced from 1 eur month to 0.5 eur month with the same functionality and no regression.
1 parent 00e7825 commit aa57f4f

File tree

2 files changed

+8
-21
lines changed

2 files changed

+8
-21
lines changed

cdk/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ You may be asked to install a package like aws-cdk, this is fine to say yes to.
6363

6464
### 5. Customize your server
6565

66+
After deploying go to the hosted zone you firstly created for your domain and click on `View query logging configuration` and select the `/aws/route53/{subdomain.domain}` log group.
67+
68+
### 6. Customize your server
69+
6670
After you've launched your minecraft server the first time and you've waited for it to finishing generating the world with all defaults, you'll need to get in, make yourself an op, tweak settings, etc. There are several ways to do this, many of which are outlined at [Usage and Customization] on the main page.
6771

6872
## Additional Configuration

cdk/lib/domain-stack.ts

+4-21
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,8 @@ export class DomainStack extends Stack {
6868
domainName: config.domainName,
6969
});
7070

71-
const subdomainHostedZone = new route53.HostedZone(
72-
this,
73-
'SubdomainHostedZone',
74-
{
75-
zoneName: subdomain,
76-
queryLogsLogGroupArn: queryLogGroup.logGroupArn,
77-
}
78-
);
79-
8071
/* Resource policy for CloudWatch Logs is needed before the zone can be created */
81-
subdomainHostedZone.node.addDependency(cloudwatchLogResourcePolicy);
82-
/* Ensure we hvae an existing hosted zone before creating our delegated zone */
83-
subdomainHostedZone.node.addDependency(rootHostedZone);
84-
85-
const nsRecord = new route53.NsRecord(this, 'NSRecord', {
86-
zone: rootHostedZone,
87-
values: subdomainHostedZone.hostedZoneNameServers as string[],
88-
recordName: subdomain,
89-
});
72+
rootHostedZone.node.addDependency(cloudwatchLogResourcePolicy);
9073

9174
const aRecord = new route53.ARecord(this, 'ARecord', {
9275
target: {
@@ -103,11 +86,11 @@ export class DomainStack extends Stack {
10386
*/
10487
ttl: Duration.seconds(30),
10588
recordName: subdomain,
106-
zone: subdomainHostedZone,
89+
zone: rootHostedZone,
10790
});
10891

10992
/* Set dependency on A record to ensure it is removed first on deletion */
110-
aRecord.node.addDependency(subdomainHostedZone);
93+
aRecord.node.addDependency(rootHostedZone);
11194

11295
const launcherLambda = new lambda.Function(this, 'LauncherLambda', {
11396
code: lambda.Code.fromAsset(path.resolve(__dirname, '../../lambda')),
@@ -153,7 +136,7 @@ export class DomainStack extends Stack {
153136
allowedPattern: '.*',
154137
description: 'Hosted zone ID for minecraft server',
155138
parameterName: constants.HOSTED_ZONE_SSM_PARAMETER,
156-
stringValue: subdomainHostedZone.hostedZoneId,
139+
stringValue: rootHostedZone.hostedZoneId,
157140
});
158141

159142
/**

0 commit comments

Comments
 (0)