Skip to content

Commit

Permalink
add ssm read policy to api lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
marjisound committed Jan 23, 2024
1 parent f8da80b commit ee35a3c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion packages/cdk/lib/transcription-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ import { GuStack } from "@guardian/cdk/lib/constructs/core";
import type { GuStackProps } from "@guardian/cdk/lib/constructs/core";
import type { App } from "aws-cdk-lib";
import { Runtime } from "aws-cdk-lib/aws-lambda";
import { Effect, PolicyStatement } from "aws-cdk-lib/aws-iam";
import { GuardianAwsAccounts } from "@guardian/private-infrastructure-config";

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

const APP_NAME = "transcription-service";
const apiId = `${APP_NAME}-${props.stage}`
const ssmPrefix = `arn:aws:ssm:${props.env.region}:${GuardianAwsAccounts.Investigations}:parameter`;

new GuApiLambda(this, "transcription-service-api", {
const apiLambda = new GuApiLambda(this, "transcription-service-api", {
fileName: "api.zip",
handler: "index.api",
runtime: Runtime.NODEJS_20_X,
Expand All @@ -24,5 +27,11 @@ export class TranscriptionService extends GuStack {
description: "API for transcription service frontend",
},
});

apiLambda.addToRolePolicy(new PolicyStatement({
effect: Effect.ALLOW,
actions: ["ssm:GetParameter", "ssm:GetParametersByPath"],
resources: [`${ssmPrefix}/${this.stage}/${this.stack}/${APP_NAME}/*`],
}));
}
}
3 changes: 2 additions & 1 deletion packages/cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@guardian/cdk": "53.0.3",
"@guardian/eslint-config-typescript": "8.0.0",
"@guardian/prettier": "5.0.0",
"@guardian/private-infrastructure-config": "github:guardian/private-infrastructure-config#v2.4.0",
"@guardian/tsconfig": "^0.2.0",
"@types/jest": "^29.5.11",
"@types/node": "20.11.5",
Expand Down Expand Up @@ -70,4 +71,4 @@
"jest.config.js"
]
}
}
}

0 comments on commit ee35a3c

Please sign in to comment.