Skip to content

Commit

Permalink
bump peer dependency cross-spawn to a patched version. Update CDK as …
Browse files Browse the repository at this point in the history
…part of the process
  • Loading branch information
Richard Bangay committed Jan 3, 2025
1 parent 1eade1e commit bd7943e
Show file tree
Hide file tree
Showing 3 changed files with 220 additions and 219 deletions.
75 changes: 42 additions & 33 deletions cdk/lib/manage-frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import type { GuAsgCapacity } from '@guardian/cdk/lib/types';
import type { App } from 'aws-cdk-lib';
import { Duration } from 'aws-cdk-lib';
import { CfnDashboard } from 'aws-cdk-lib/aws-cloudwatch';
import { InstanceClass, InstanceSize, InstanceType } from 'aws-cdk-lib/aws-ec2';
import {
InstanceClass,
InstanceSize,
InstanceType,
UserData,
} from 'aws-cdk-lib/aws-ec2';
import { Protocol } from 'aws-cdk-lib/aws-elasticloadbalancingv2';
import { LogGroup, RetentionDays } from 'aws-cdk-lib/aws-logs';
import { CfnRecordSet } from 'aws-cdk-lib/aws-route53';
Expand Down Expand Up @@ -45,38 +50,42 @@ export class ManageFrontend extends GuStack {
default: `/${this.stage}/${this.stack}/${app}/serverRavenDSN`,
});

// intentionally removed tabs from the following string for bash's sake!
const userData = `#!/bin/bash -ev
# get runnable tar from S3
aws --region ${this.region} s3 cp s3://membership-dist/${this.stack}/${this.stage}/${app}/manage-frontend.zip /tmp
mkdir /etc/gu
unzip /tmp/manage-frontend.zip -d /etc/gu/dist/
# add user
groupadd manage-frontend
useradd -r -s /usr/bin/nologin -g manage-frontend manage-frontend
touch /var/log/manage-frontend.log
chown -R manage-frontend:manage-frontend /etc/gu
chown manage-frontend:manage-frontend /var/log/manage-frontend.log
# write out systemd file
cat >/etc/systemd/system/manage-frontend.service <<EOL
[Service]
ExecStart=/usr/bin/node /etc/gu/dist/server.js
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=manage-frontend
User=manage-frontend
Group=manage-frontend
Environment=STAGE=${this.stage}
Environment=CLIENT_DSN=${clientRavenDSN.valueAsString}
Environment=SERVER_DSN=${serverRavenDSN.valueAsString}
[Install]
WantedBy=multi-user.target
EOL
# RUN
systemctl enable manage-frontend
systemctl start manage-frontend
/opt/cloudwatch-logs/configure-logs application ${this.stack} ${this.stage} ${app} /var/log/manage-frontend.log`;
const userData = UserData.forLinux();
userData.addCommands(
[
`#!/bin/bash -ev`,
`# get runnable tar from S3`,
`aws --region ${this.region} s3 cp s3://membership-dist/${this.stack}/${this.stage}/${app}/manage-frontend.zip /tmp`,
`mkdir /etc/gu`,
`unzip /tmp/manage-frontend.zip -d /etc/gu/dist/`,
`# add user`,
`groupadd manage-frontend`,
`useradd -r -s /usr/bin/nologin -g manage-frontend manage-frontend`,
`touch /var/log/manage-frontend.log`,
`chown -R manage-frontend:manage-frontend /etc/gu`,
`chown manage-frontend:manage-frontend /var/log/manage-frontend.log`,
`# write out systemd file`,
`cat >/etc/systemd/system/manage-frontend.service <<EOL`,
`[Service]`,
`ExecStart=/usr/bin/node /etc/gu/dist/server.js`,
`Restart=always`,
`StandardOutput=syslog`,
`StandardError=syslog`,
`SyslogIdentifier=manage-frontend`,
`User=manage-frontend`,
`Group=manage-frontend`,
`Environment=STAGE=${this.stage}`,
`Environment=CLIENT_DSN=${clientRavenDSN.valueAsString}`,
`Environment=SERVER_DSN=${serverRavenDSN.valueAsString}`,
`[Install]`,
`WantedBy=multi-user.target`,
`EOL`,
`# RUN`,
`systemctl enable manage-frontend`,
`systemctl start manage-frontend`,
`/opt/cloudwatch-logs/configure-logs application ${this.stack} ${this.stage} ${app} /var/log/manage-frontend.log`,
].join('\n'),
);

const logGroup = new LogGroup(this, 'ManageFrontendLogGroup', {
logGroupName: `support-manage-frontend-${this.stage}`,
Expand Down
10 changes: 5 additions & 5 deletions cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
"deploy-code": "cdk deploy --path-metadata false --version-reporting false ManageFrontend-CODE"
},
"devDependencies": {
"@guardian/cdk": "50.10.6",
"@guardian/cdk": "61.1.0",
"@guardian/eslint-config-typescript": "1.0.7",
"@guardian/prettier": "1.0.0",
"@types/jest": "^27.5.0",
"@types/node": "18.7.14",
"aws-cdk": "2.87.0",
"aws-cdk-lib": "2.87.0",
"constructs": "10.2.69",
"aws-cdk": "2.172.0",
"aws-cdk-lib": "2.172.0",
"constructs": "10.4.2",
"eslint": "^8.23.0",
"jest": "^27.5.1",
"prettier": "^2.7.1",
"source-map-support": "^0.5.20",
"source-map-support": "0.5.21",
"ts-jest": "^27.1.4",
"ts-node": "^10.9.1",
"typescript": "~4.7.4"
Expand Down
Loading

0 comments on commit bd7943e

Please sign in to comment.