Skip to content

Commit

Permalink
check region is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
marjisound committed Jan 23, 2024
1 parent 27b6177 commit 5bf91df
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 49 deletions.
66 changes: 19 additions & 47 deletions packages/cdk/lib/__snapshots__/transcription-service.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ exports[`The TranscriptionService stack matches the snapshot 1`] = `
{
"Ref": "transcriptionserviceapitranscriptionserviceTESTD0A6228F",
},
".execute-api.",
{
"Ref": "AWS::Region",
},
".",
".execute-api.test-region.",
{
"Ref": "AWS::URLSuffix",
},
Expand Down Expand Up @@ -204,11 +200,7 @@ exports[`The TranscriptionService stack matches the snapshot 1`] = `
"Fn::Join": [
"",
[
"arn:aws:ssm:",
{
"Ref": "AWS::Region",
},
":",
"arn:aws:ssm:test-region:",
{
"Ref": "AWS::AccountId",
},
Expand All @@ -227,11 +219,7 @@ exports[`The TranscriptionService stack matches the snapshot 1`] = `
"Fn::Join": [
"",
[
"arn:aws:ssm:",
{
"Ref": "AWS::Region",
},
":",
"arn:aws:ssm:test-region:",
{
"Ref": "AWS::AccountId",
},
Expand All @@ -240,6 +228,14 @@ exports[`The TranscriptionService stack matches the snapshot 1`] = `
],
},
},
{
"Action": [
"ssm:GetParameter",
"ssm:GetParametersByPath",
],
"Effect": "Allow",
"Resource": "arn:aws:ssm:test-region:745349931791:parameter/TEST/investigations/transcription-service/*",
},
],
"Version": "2012-10-17",
},
Expand Down Expand Up @@ -270,11 +266,7 @@ exports[`The TranscriptionService stack matches the snapshot 1`] = `
{
"Ref": "AWS::Partition",
},
":execute-api:",
{
"Ref": "AWS::Region",
},
":",
":execute-api:test-region:",
{
"Ref": "AWS::AccountId",
},
Expand Down Expand Up @@ -307,11 +299,7 @@ exports[`The TranscriptionService stack matches the snapshot 1`] = `
{
"Ref": "AWS::Partition",
},
":execute-api:",
{
"Ref": "AWS::Region",
},
":",
":execute-api:test-region:",
{
"Ref": "AWS::AccountId",
},
Expand Down Expand Up @@ -345,11 +333,7 @@ exports[`The TranscriptionService stack matches the snapshot 1`] = `
{
"Ref": "AWS::Partition",
},
":apigateway:",
{
"Ref": "AWS::Region",
},
":lambda:path/2015-03-31/functions/",
":apigateway:test-region:lambda:path/2015-03-31/functions/",
{
"Fn::GetAtt": [
"transcriptionserviceapi022C22E7",
Expand Down Expand Up @@ -473,7 +457,7 @@ exports[`The TranscriptionService stack matches the snapshot 1`] = `
},
"Type": "AWS::ApiGateway::RestApi",
},
"transcriptionserviceapitranscriptionserviceTESTDeployment439CFDDA9f3c8219f1b15f132dbe2e1761e6cad6": {
"transcriptionserviceapitranscriptionserviceTESTDeployment439CFDDA239aa57b071d08d4c79426ec1366bceb": {
"DependsOn": [
"transcriptionserviceapitranscriptionserviceTESTproxyANY65A12BB3",
"transcriptionserviceapitranscriptionserviceTESTproxy923E1B16",
Expand All @@ -493,7 +477,7 @@ exports[`The TranscriptionService stack matches the snapshot 1`] = `
],
"Properties": {
"DeploymentId": {
"Ref": "transcriptionserviceapitranscriptionserviceTESTDeployment439CFDDA9f3c8219f1b15f132dbe2e1761e6cad6",
"Ref": "transcriptionserviceapitranscriptionserviceTESTDeployment439CFDDA239aa57b071d08d4c79426ec1366bceb",
},
"RestApiId": {
"Ref": "transcriptionserviceapitranscriptionserviceTESTD0A6228F",
Expand Down Expand Up @@ -554,11 +538,7 @@ exports[`The TranscriptionService stack matches the snapshot 1`] = `
{
"Ref": "AWS::Partition",
},
":apigateway:",
{
"Ref": "AWS::Region",
},
":lambda:path/2015-03-31/functions/",
":apigateway:test-region:lambda:path/2015-03-31/functions/",
{
"Fn::GetAtt": [
"transcriptionserviceapi022C22E7",
Expand Down Expand Up @@ -597,11 +577,7 @@ exports[`The TranscriptionService stack matches the snapshot 1`] = `
{
"Ref": "AWS::Partition",
},
":execute-api:",
{
"Ref": "AWS::Region",
},
":",
":execute-api:test-region:",
{
"Ref": "AWS::AccountId",
},
Expand Down Expand Up @@ -634,11 +610,7 @@ exports[`The TranscriptionService stack matches the snapshot 1`] = `
{
"Ref": "AWS::Partition",
},
":execute-api:",
{
"Ref": "AWS::Region",
},
":",
":execute-api:test-region:",
{
"Ref": "AWS::AccountId",
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cdk/lib/transcription-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TranscriptionService } from "./transcription-service";
describe("The TranscriptionService stack", () => {
it("matches the snapshot", () => {
const app = new App();
const stack = new TranscriptionService(app, "TranscriptionService", { stack: "investigations", stage: "TEST" });
const stack = new TranscriptionService(app, "TranscriptionService", { stack: "investigations", stage: "TEST", env: { region: "test-region" } });
const template = Template.fromStack(stack);
expect(template.toJSON()).toMatchSnapshot();
});
Expand Down
4 changes: 3 additions & 1 deletion packages/cdk/lib/transcription-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export class TranscriptionService extends GuStack {
super(scope, id, props);

const APP_NAME = "transcription-service";
const apiId = `${APP_NAME}-${props.stage}`
const apiId = `${APP_NAME}-${props.stage}`;
if (!props.env?.region) throw new Error("region not provided in props");

const ssmPrefix = `arn:aws:ssm:${props.env.region}:${GuardianAwsAccounts.Investigations}:parameter`;

const apiLambda = new GuApiLambda(this, "transcription-service-api", {
Expand Down

0 comments on commit 5bf91df

Please sign in to comment.