Skip to content

Commit 1dac961

Browse files
committed
Update with main
2 parents 34bbfe6 + 2ba4f29 commit 1dac961

File tree

4 files changed

+25
-102
lines changed

4 files changed

+25
-102
lines changed
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy to Production
1+
name: Deploy to Development
22

33
on:
44
push:
@@ -30,15 +30,10 @@ jobs:
3030
cd backend
3131
npm test
3232
33-
- name: Run CDK tests
34-
run: |
35-
cd backend
36-
npm run test:cdk
37-
3833
deploy:
3934
needs: test
4035
runs-on: ubuntu-latest
41-
environment: production
36+
environment: development
4237

4338
steps:
4439
- uses: actions/checkout@v4
@@ -68,9 +63,9 @@ jobs:
6863
- name: Deploy to AWS
6964
run: |
7065
cd backend
71-
npm run cdk deploy -- \
66+
npm run cdk deploy ai-team-medical-reports-stack-development -- \
7267
--require-approval never \
73-
--context environment=production
68+
--context environment=development
7469
env:
7570
CDK_DEFAULT_ACCOUNT: ${{ secrets.AWS_ACCOUNT_ID }}
7671
CDK_DEFAULT_REGION: us-east-1

.github/workflows/deploy-staging.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

backend/src/iac/backend-stack.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ import * as servicediscovery from 'aws-cdk-lib/aws-servicediscovery';
88
import * as iam from 'aws-cdk-lib/aws-iam';
99
import * as elbv2 from 'aws-cdk-lib/aws-elasticloadbalancingv2';
1010
import * as s3 from 'aws-cdk-lib/aws-s3';
11+
import * as ssm from 'aws-cdk-lib/aws-ssm';
1112

1213
import { Construct } from 'constructs';
1314
import { AttributeType, BillingMode, Table } from 'aws-cdk-lib/aws-dynamodb';
1415
import { RemovalPolicy } from 'aws-cdk-lib';
1516

1617
interface BackendStackProps extends cdk.StackProps {
1718
environment: string;
18-
cognitoClientId: string;
19-
cognitoUserPoolId: string;
2019
}
2120

2221
export class BackendStack extends cdk.Stack {
@@ -26,6 +25,24 @@ export class BackendStack extends cdk.Stack {
2625
const isProd = props.environment === 'production';
2726
const appName = 'AIMedicalReport';
2827

28+
// Get Cognito User Pool ID from SSM Parameter Store
29+
const userPoolId = ssm.StringParameter.fromStringParameterAttributes(
30+
this,
31+
`${appName}UserPoolIdParam-${props.environment}`,
32+
{
33+
parameterName: `/${appName}/${props.environment}/cognito-user-pool-id`,
34+
},
35+
).stringValue;
36+
37+
// Get Cognito Client ID from SSM Parameter Store
38+
const clientId = ssm.StringParameter.fromStringParameterAttributes(
39+
this,
40+
`${appName}ClientIdParam-${props.environment}`,
41+
{
42+
parameterName: `/${appName}/${props.environment}/cognito-client-id`,
43+
},
44+
).stringValue;
45+
2946
// VPC
3047
const vpc = new ec2.Vpc(this, `${appName}VPC`, {
3148
vpcName: `${appName}VPC-${props.environment}`,
@@ -82,11 +99,7 @@ export class BackendStack extends cdk.Stack {
8299
});
83100

84101
// Cognito User Pool
85-
const userPool = cognito.UserPool.fromUserPoolId(
86-
this,
87-
`${appName}UserPool`,
88-
props.cognitoUserPoolId || 'us-east-1_PszlvSmWc',
89-
);
102+
const userPool = cognito.UserPool.fromUserPoolId(this, `${appName}UserPool`, userPoolId);
90103

91104
// Cognito domain
92105
const userPoolDomain = cognito.UserPoolDomain.fromDomainName(
@@ -99,7 +112,7 @@ export class BackendStack extends cdk.Stack {
99112
const userPoolClient = cognito.UserPoolClient.fromUserPoolClientId(
100113
this,
101114
`${appName}UserPoolClient-${props.environment}`,
102-
props.cognitoClientId,
115+
clientId,
103116
);
104117

105118
// Security Group for Fargate service

backend/src/iac/cdk.index.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,12 @@ export function main() {
1414

1515
console.log('NODE_ENV', process.env.NODE_ENV);
1616

17-
const cognitoClientId = process.env.AWS_COGNITO_CLIENT_ID;
18-
const cognitoUserPoolId = process.env.AWS_COGNITO_USER_POOL_ID;
19-
20-
if (!cognitoClientId || !cognitoUserPoolId) {
21-
throw new Error('AWS_COGNITO_CLIENT_ID and AWS_COGNITO_USER_POOL_ID must be set');
22-
}
23-
2417
void new BackendStack(app, `ai-team-medical-reports-stack-${process.env.NODE_ENV}`, {
2518
environment: process.env.NODE_ENV || 'development',
2619
env: {
2720
account: process.env.CDK_DEFAULT_ACCOUNT,
2821
region: process.env.CDK_DEFAULT_REGION || 'us-east-1',
2922
},
30-
cognitoClientId: cognitoClientId,
31-
cognitoUserPoolId: cognitoUserPoolId,
3223
});
3324

3425
return app;

0 commit comments

Comments
 (0)