Skip to content

Commit

Permalink
add cdk and create skeleton stack for mobile purchases
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbjacobson committed Mar 4, 2024
1 parent 033f002 commit 7181db8
Show file tree
Hide file tree
Showing 12 changed files with 4,572 additions and 136 deletions.
11 changes: 11 additions & 0 deletions cdk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.js
!jest.config.js
!jest.setup.js
!.eslintrc.js
*.d.ts
node_modules
dist

# CDK asset staging directory
.cdk.staging
cdk.out
5 changes: 5 additions & 0 deletions cdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Infrastructure

This directory defines the components to be deployed to AWS.

See [`package.json`](./package.json) for a list of available scripts.
7 changes: 7 additions & 0 deletions cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import "source-map-support/register";
import { GuRoot } from "@guardian/cdk/lib/constructs/root";
import { MobilePurchases } from "../lib/mobile-purchases";

const app = new GuRoot();
new MobilePurchases(app, "MobilePurchases-euwest-1-CODE", { stack: "mobile", stage: "CODE", env: { region: "eu-west-1" } });
new MobilePurchases(app, "MobilePurchases-euwest-1-PROD", { stack: "mobile", stage: "PROD", env: { region: "eu-west-1" } });
7 changes: 7 additions & 0 deletions cdk/cdk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"app": "npx ts-node bin/cdk.ts",
"context": {
"aws-cdk:enableDiffNoFail": "true",
"@aws-cdk/core:stackRelativeExports": "true"
}
}
1 change: 1 addition & 0 deletions cdk/jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jest.mock("@guardian/cdk/lib/constants/tracking-tag");
10 changes: 10 additions & 0 deletions cdk/lib/__snapshots__/mobile-purchases.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`The MobilePurchases stack matches the snapshot 1`] = `
{
"Metadata": {
"gu:cdk:constructs": [],
"gu:cdk:version": "TEST",
},
}
`;
12 changes: 12 additions & 0 deletions cdk/lib/mobile-purchases.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { App } from "aws-cdk-lib";
import { Template } from "aws-cdk-lib/assertions";
import { MobilePurchases } from "./mobile-purchases";

describe("The MobilePurchases stack", () => {
it("matches the snapshot", () => {
const app = new App();
const stack = new MobilePurchases(app, "MobilePurchases", { stack: "mobile", stage: "TEST" });
const template = Template.fromStack(stack);
expect(template.toJSON()).toMatchSnapshot();
});
});
9 changes: 9 additions & 0 deletions cdk/lib/mobile-purchases.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { GuStackProps } from "@guardian/cdk/lib/constructs/core";
import { GuStack } from "@guardian/cdk/lib/constructs/core";
import type { App } from "aws-cdk-lib";

export class MobilePurchases extends GuStack {
constructor(scope: App, id: string, props: GuStackProps) {
super(scope, id, props);
}
}
72 changes: 72 additions & 0 deletions cdk/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"name": "cdk",
"version": "0.0.0",
"private": true,
"scripts": {
"build": "tsc",
"test": "jest",
"test-update": "jest -u",
"format": "prettier --write \"{lib,bin}/**/*.ts\"",
"lint": "eslint lib/** bin/** --ext .ts --no-error-on-unmatched-pattern",
"synth": "cdk synth --path-metadata false --version-reporting false",
"diff": "cdk diff --path-metadata false --version-reporting false"
},
"devDependencies": {
"@guardian/cdk": "54.1.0",
"@guardian/eslint-config-typescript": "8.0.0",
"@guardian/prettier": "5.0.0",
"@guardian/tsconfig": "^0.2.0",
"@types/jest": "^29.5.12",
"@types/node": "20.11.20",
"aws-cdk": "2.127.0",
"aws-cdk-lib": "2.127.0",
"constructs": "10.3.0",
"eslint": "^8.56.0",
"jest": "^29.7.0",
"prettier": "^3.2.5",
"source-map-support": "^0.5.20",
"ts-jest": "^29.1.2",
"ts-node": "^10.9.2",
"typescript": "5.1.6"
},
"prettier": "@guardian/prettier",
"jest": {
"testMatch": [
"<rootDir>/lib/**/*.test.ts"
],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"setupFilesAfterEnv": [
"./jest.setup.js"
]
},
"eslintConfig": {
"root": true,
"env": {
"node": true,
"jest": true
},
"extends": [
"@guardian/eslint-config-typescript"
],
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/no-inferrable-types": 0,
"import/no-namespace": 2
},
"ignorePatterns": [
"**/*.js",
"node_modules",
"cdk.out",
".eslintrc.js",
"jest.config.js"
]
}
}
12 changes: 12 additions & 0 deletions cdk/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "@guardian/tsconfig/tsconfig.json",
"compilerOptions": {
"module": "CommonJS"
},
"include": ["lib/**/*", "bin/**/*"],
"exclude": [
"node_modules",
"cdk.out",
"lib/**/__snapshots__/**"
]
}
Loading

0 comments on commit 7181db8

Please sign in to comment.