Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/gmail-viewer-cdk/bin/gmail-viewer-cdk.js

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

4 changes: 2 additions & 2 deletions examples/gmail-viewer-cdk/bin/gmail-viewer-cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ new GmailViewerCdkStack(app, 'GmailViewerCdkStack', {
gitHubBranch: 'main',
codeConnectionArn: 'arn:aws:codeconnections:ca-central-1:239030031457:connection/29fe5c11-23d2-4c10-a81d-4e880b12e2c6',
useGitHubWebhooks: false,
apiCustomDomainName: 'mail.dyanet.com',
certificateArn: 'arn:aws:acm:ca-central-1:239030031457:certificate/af9150f1-4635-4154-8b19-e5449d57e971',
apiCustomDomainName: 'demo.dyanet.com',
certificateArn: 'arn:aws:acm:ca-central-1:239030031457:certificate/cb01610f-dddd-44e1-abd9-0672f0dc3355',
});
21 changes: 9 additions & 12 deletions examples/gmail-viewer-cdk/lib/gmail-viewer-cdk-stack.js

Large diffs are not rendered by default.

19 changes: 8 additions & 11 deletions examples/gmail-viewer-cdk/lib/gmail-viewer-cdk-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class GmailViewerCdkStack extends cdk.Stack {
const googleClientId = props.googleClientId || 'PLACEHOLDER_GOOGLE_CLIENT_ID';
const googleClientSecret = props.googleClientSecret || 'PLACEHOLDER_GOOGLE_CLIENT_SECRET';
const sessionSecretValue = props.sessionSecretValue || 'PLACEHOLDER_SESSION_SECRET';
const apiDomain = props.apiCustomDomainName ?? process.env.API_CUSTOM_DOMAIN ?? 'mail.dyanet.com';
const apiDomain = props.apiCustomDomainName ?? process.env.API_CUSTOM_DOMAIN ?? 'demo.dyanet.com';
const certArn = props.certificateArn ?? this.node.tryGetContext('certificateArn') ?? process.env.CERTIFICATE_ARN;
const zoneId = props.hostedZoneId ?? '';
const hasCustomDomain = Boolean(certArn && apiDomain);
Expand Down Expand Up @@ -163,13 +163,16 @@ export class GmailViewerCdkStack extends cdk.Stack {
name: 'mail-example', namespace, dnsRecordType: servicediscovery.DnsRecordType.SRV, dnsTtl: nsTtl, routingPolicy: servicediscovery.RoutingPolicy.WEIGHTED, customHealthCheck: { failureThreshold: 1 },
});

// Secrets Manager - single secret with GOOGLE_CLIENT_SECRET and SESSION_SECRET
// Secrets Manager - all config values for the application
const appSecrets = new secretsmanager.Secret(this, 'AppSecrets', {
secretName: `${ssmPrefix}/secrets`,
description: 'Application secrets for mail-example',
secretName: `${ssmPrefix}/config`,
description: 'Application configuration for mail-example',
secretObjectValue: {
GOOGLE_CLIENT_ID: cdk.SecretValue.unsafePlainText(googleClientId),
GOOGLE_CLIENT_SECRET: cdk.SecretValue.unsafePlainText(googleClientSecret),
SESSION_SECRET: cdk.SecretValue.unsafePlainText(sessionSecretValue),
BASE_URL: cdk.SecretValue.unsafePlainText(baseUrl.toString()),
PORT: cdk.SecretValue.unsafePlainText(containerPort.toString()),
},
});

Expand All @@ -182,20 +185,14 @@ export class GmailViewerCdkStack extends cdk.Stack {
taskRole.addToPolicy(new iam.PolicyStatement({ actions: ['ssm:GetParameter', 'ssm:GetParameters', 'ssm:GetParametersByPath', 'kms:Decrypt'], resources: [`arn:aws:ssm:${this.region}:${this.account}:parameter${ssmPrefix}*`, `arn:aws:kms:${this.region}:${this.account}:key/*`] }));
taskRole.addToPolicy(new iam.PolicyStatement({ actions: ['secretsmanager:GetSecretValue'], resources: [appSecrets.secretArn] }));

// SSM Parameters (L2) - create before task definition so they can be referenced
const ssmBaseUrl = new ssm.StringParameter(this, 'SsmBaseUrl', { parameterName: `${ssmPrefix}/env/BASE_URL`, stringValue: baseUrl.toString() });
const ssmGoogleClientId = new ssm.StringParameter(this, 'SsmGoogleClientId', { parameterName: `${ssmPrefix}/env/GOOGLE_CLIENT_ID`, stringValue: googleClientId });
new ssm.StringParameter(this, 'SsmPort', { parameterName: `${ssmPrefix}/env/PORT`, stringValue: containerPort.toString() });
new ssm.StringParameter(this, 'SsmPublicEnv', { parameterName: `${ssmPrefix}/env/NODE_ENV`, stringValue: publicEnvValue });

// ECS Task Definition (L2)
const taskDef = new ecs.FargateTaskDefinition(this, 'AppTaskDefinition', { family: 'mail-example', cpu: containerCpu, memoryLimitMiB: containerMemory, executionRole: taskExecRole, taskRole });
taskDef.addContainer('mail-example', {
image: ecs.ContainerImage.fromEcrRepository(ecrRepo, 'latest'), portMappings: [{ containerPort }],
logging: ecs.LogDrivers.awsLogs({ logGroup: appLogGroup, streamPrefix: 'mail-example' }),
environment: { CONFIG_SSM_PREFIX: ssmPrefix, PORT: containerPort.toString(), BASE_URL: baseUrl.toString(), NODE_ENV: publicEnvValue },
secrets: {
GOOGLE_CLIENT_ID: ecs.Secret.fromSsmParameter(ssmGoogleClientId),
GOOGLE_CLIENT_ID: ecs.Secret.fromSecretsManager(appSecrets, 'GOOGLE_CLIENT_ID'),
GOOGLE_CLIENT_SECRET: ecs.Secret.fromSecretsManager(appSecrets, 'GOOGLE_CLIENT_SECRET'),
SESSION_SECRET: ecs.Secret.fromSecretsManager(appSecrets, 'SESSION_SECRET'),
},
Expand Down
98 changes: 98 additions & 0 deletions examples/gmail-viewer/package-lock.json

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

1 change: 1 addition & 0 deletions examples/gmail-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@aws-sdk/client-s3": "^3.0.0",
"@aws-sdk/client-secrets-manager": "^3.0.0",
"@aws-sdk/client-ssm": "^3.0.0",
"@aws-sdk/credential-providers": "^3.0.0",
"@dyanet/config-aws": "^1.0.3",
"@dyanet/imap": "^0.5.2",
"express": "^4.21.0",
Expand Down
3 changes: 2 additions & 1 deletion tests/property/protocol.property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ const responseTextArb = fc.stringOf(

/**
* Generates valid IMAP atoms (no special characters)
* Excludes NIL (case-insensitive) as it's a reserved keyword
*/
const atomArb = fc.stringOf(
fc.constantFrom(...'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._-'),
{ minLength: 1, maxLength: 20 }
);
).filter(s => s.toUpperCase() !== 'NIL');

/**
* Generates valid quoted strings (may contain spaces)
Expand Down