Skip to content

Commit

Permalink
import cfn yaml into cdk
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbjacobson committed Mar 11, 2024
1 parent edd5208 commit 46ba196
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 36 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@ jobs:
buildNumberOffset: 2740
configPath: riff-raff.yaml
contentDirectories: |
mobile-purchases-feast-cloudformation:
mobile-purchases-cloudformation:
- cdk/cdk.out/MobilePurchasesFeast-CODE.template.json
- cdk/cdk.out/MobilePurchasesFeast-PROD.template.json
mobile-purchases-cloudformation:
- cloudformation.yaml
mobile-purchases-dynamo-cloudformation:
- dynamo.cloudformation.yaml
mobile-purchases-exports-cloudformation:
Expand Down
6 changes: 3 additions & 3 deletions cdk/bin/cdk.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "source-map-support/register";
import { GuRoot } from "@guardian/cdk/lib/constructs/root";
import { MobilePurchasesFeast } from "../lib/mobile-purchases-feast";
import { MobilePurchases } from "../lib/mobile-purchases";

const app = new GuRoot();
new MobilePurchasesFeast(app, "MobilePurchasesFeast-CODE", { stack: "mobile", stage: "CODE", env: { region: "eu-west-1" } });
new MobilePurchasesFeast(app, "MobilePurchasesFeast-PROD", { stack: "mobile", stage: "PROD", env: { region: "eu-west-1" } });
new MobilePurchases(app, "MobilePurchases-CODE", { stack: "mobile", stage: "CODE", env: { region: "eu-west-1" } });
new MobilePurchases(app, "MobilePurchases-PROD", { stack: "mobile", stage: "PROD", env: { region: "eu-west-1" } });
10 changes: 0 additions & 10 deletions cdk/lib/__snapshots__/mobile-purchases-feast.test.ts.snap

This file was deleted.

9 changes: 0 additions & 9 deletions cdk/lib/mobile-purchases-feast.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { App } from "aws-cdk-lib";
import { Template } from "aws-cdk-lib/assertions";
import { MobilePurchasesFeast } from "./mobile-purchases-feast";
import { MobilePurchases } from "./mobile-purchases";

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

Check failure on line 4 in cdk/lib/mobile-purchases.ts

View workflow job for this annotation

GitHub Actions / CI

`path` import should occur before type import of `@guardian/cdk/lib/constructs/core`
import {CfnInclude} from "aws-cdk-lib/cloudformation-include";

export class MobilePurchases extends GuStack {
constructor(scope: App, id: string, props: GuStackProps) {
super(scope, id, props);

// ---- Existing CFN template ---- //
const yamlTemplateFilePath = path.join(__dirname, "../..", "cloudformation.yaml");
new CfnInclude(this, "YamlTemplate", {
templateFile: yamlTemplateFilePath,
});
}
}
11 changes: 3 additions & 8 deletions riff-raff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@ templates:
prefixStack: false

deployments:
mobile-purchases-feast-cloudformation:
type: cloud-formation
parameters:
templateStagePaths:
CODE: MobilePurchasesFeast-CODE.template.json
PROD: MobilePurchasesFeast-PROD.template.json

mobile-purchases-cloudformation:
type: cloud-formation
parameters:
templatePath: cloudformation.yaml
templateStagePaths:
CODE: MobilePurchases-CODE.template.json
PROD: MobilePurchases-PROD.template.json

mobile-purchases-dynamo-cloudformation:
type: cloud-formation
Expand Down

0 comments on commit 46ba196

Please sign in to comment.