Skip to content

Commit

Permalink
Merge pull request #1380 from aligent/feature/DO-1631_add_secretsmana…
Browse files Browse the repository at this point in the history
…ger_support
  • Loading branch information
gowrizrh authored May 27, 2024
2 parents c7384ab + 00f3725 commit 26995d4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

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

24 changes: 18 additions & 6 deletions packages/graphql-mesh-server/lib/fargate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,20 @@ export interface MeshServiceProps {
};
/**
* SSM values to pass through to the container as secrets
*
* @deprecated - Use secrets instead
*/
secrets?: { [key: string]: ssm.IStringParameter | ssm.IStringListParameter };
ssmSecrets?: {
[key: string]: ssm.IStringParameter | ssm.IStringListParameter;
};

/**
* ECS Secrets to pass through to the container as secrets
*
* The key values can be referenced from either SSM or Secrets manager
*/
secrets?: { [key: string]: ecs.Secret };

/**
* Name of the WAF
* Defaults to 'graphql-mesh-web-acl'
Expand Down Expand Up @@ -268,10 +280,10 @@ export class MeshService extends Construct {
}

// Construct secrets from provided ssm values
const secrets: { [key: string]: ecs.Secret } = {};
props.secrets = props.secrets || {};
for (const [key, ssm] of Object.entries(props.secrets)) {
secrets[key] = ecs.Secret.fromSsmParameter(ssm);
const ssmSecrets: { [key: string]: ecs.Secret } = {};
props.ssmSecrets = props.ssmSecrets || {};
for (const [key, ssm] of Object.entries(props.ssmSecrets)) {
ssmSecrets[key] = ecs.Secret.fromSsmParameter(ssm);
}

// Configure a custom log driver and group
Expand All @@ -295,7 +307,7 @@ export class MeshService extends Construct {
image: ecs.ContainerImage.fromEcrRepository(this.repository),
enableLogging: true, // default
containerPort: 4000, // graphql mesh gateway port
secrets: secrets,
secrets: props.secrets ? props.secrets : ssmSecrets, // Prefer v2 secrets using secrets manager
environment: environment,
logDriver: logDriver,
taskRole: new iam.Role(this, "MeshTaskRole", {
Expand Down
15 changes: 14 additions & 1 deletion packages/graphql-mesh-server/lib/graphql-mesh-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { LogGroup } from "aws-cdk-lib/aws-logs";
import { Topic } from "aws-cdk-lib/aws-sns";
import { Alarm } from "aws-cdk-lib/aws-cloudwatch";
import { Maintenance } from "./maintenance";
import { Secret } from "aws-cdk-lib/aws-ecs";

export type MeshHostingProps = {
/**
Expand Down Expand Up @@ -66,8 +67,20 @@ export type MeshHostingProps = {
};
/**
* SSM values to pass through to the container as secrets
*
* @deprecated - Use secrets instead
*/
secrets?: { [key: string]: ssm.IStringParameter | ssm.IStringListParameter };
ssmSecrets?: {
[key: string]: ssm.IStringParameter | ssm.IStringListParameter;
};

/**
* ECS Secrets to pass through to the container as secrets
*
* The key values can be referenced from either SSM or Secrets manager
*/
secrets?: { [key: string]: Secret };

/**
* Pass custom cpu scaling steps
* Default value:
Expand Down

0 comments on commit 26995d4

Please sign in to comment.