Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eregs 2859 #1516

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d043d4c
EREGS-2858: Convert Static-Assets serverless to CDK
addis-samtek Jan 2, 2025
8e1ed3d
add api stack
addis-samtek Jan 6, 2025
bc8833e
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 11, 2025
c4357c5
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 12, 2025
6429db1
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 12, 2025
812c244
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 12, 2025
18ad5bd
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 12, 2025
0edc228
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 12, 2025
350f693
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 12, 2025
d490779
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 12, 2025
bf1256f
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 12, 2025
0a76fc2
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 12, 2025
9fff1f3
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 13, 2025
8816f59
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 13, 2025
b8e8c07
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 13, 2025
edb28fe
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 13, 2025
546303a
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 13, 2025
725093b
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 13, 2025
a4095cb
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 13, 2025
fd2ee18
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 13, 2025
884172d
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 13, 2025
5f0b057
EREGS-2859: Add API stack CDK resources
addis-samtek Jan 13, 2025
f72aa5d
Add Dockerfile
addis-samtek Jan 14, 2025
6a64b73
Add Dockerfile
addis-samtek Jan 14, 2025
bf97e88
Add SSm permission
addis-samtek Jan 14, 2025
8a47069
Add SSm permission
addis-samtek Jan 14, 2025
fe41137
Add SSm permission
addis-samtek Jan 14, 2025
cf69baf
Add SSm permission
addis-samtek Jan 14, 2025
61a13af
Add SSm permission
addis-samtek Jan 14, 2025
026054a
Add SSm permission
addis-samtek Jan 14, 2025
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
105 changes: 101 additions & 4 deletions .github/workflows/deploy-experimental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,58 @@ jobs:
npm install
serverless deploy --stage dev${PR}
popd
deploy-static-asset-cdk:
if: github.event.action != 'closed'
runs-on: ubuntu-22.04
environment:
name: "dev"
env:
ENVIRONMENT_NAME: "dev"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true

- name: Find PR number
uses: jwalton/gh-find-current-pr@v1
id: findPr
with:
state: open

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-east-1

- name: Deploy Static-Asset
if: success() && steps.findPr.outputs.number
env:
PR_NUMBER: ${{ steps.findPr.outputs.pr }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
CDK_DEBUG: true
run: |
pushd cdk-eregs
npm install -g aws-cdk@latest @aws-sdk/client-ssm
npm install fs-extra
npm install --save-dev @types/fs-extra

npm install

# Get exact stack names
STATICASSET_STACK="cms-eregs-eph-$PR_NUMBER-static-assets"


cdk deploy ${STATICASSET_STACK} \
-c environment=${{ env.ENVIRONMENT_NAME }} \
--require-approval never \
--exclusively \
--app "npx ts-node bin/zip-lambdas.ts"
popd
deploy-zip-lambdas-cdk:
needs: deploy-static-asset-cdk
if: github.event.action != 'closed'
runs-on: ubuntu-22.04
environment:
Expand Down Expand Up @@ -123,7 +174,7 @@ jobs:
popd

deploy-text-extractor-cdk:
needs: deploy-zip-lambdas-cdk
needs: [deploy-static-asset-cdk,deploy-zip-lambdas-cdk]
if: github.event.action != 'closed'
runs-on: ubuntu-22.04
environment:
Expand Down Expand Up @@ -170,7 +221,7 @@ jobs:
popd

deploy-fr-parser-cdk:
needs: [deploy-zip-lambdas-cdk, deploy-text-extractor-cdk]
needs: [deploy-static-asset-cdk,deploy-zip-lambdas-cdk, deploy-text-extractor-cdk]
if: github.event.action != 'closed'
runs-on: ubuntu-22.04
environment:
Expand Down Expand Up @@ -217,7 +268,7 @@ jobs:
popd

deploy-ecfr-parser-cdk:
needs: [deploy-zip-lambdas-cdk, deploy-text-extractor-cdk, deploy-fr-parser-cdk]
needs: [deploy-static-asset-cdk,deploy-zip-lambdas-cdk, deploy-text-extractor-cdk, deploy-fr-parser-cdk]
if: github.event.action != 'closed'
runs-on: ubuntu-22.04
environment:
Expand Down Expand Up @@ -262,9 +313,55 @@ jobs:
--exclusively \
--app "npx ts-node bin/docker-lambdas.ts"
popd
deploy-site-lambda-cdk:
needs: [deploy-static-asset-cdk,deploy-zip-lambdas-cdk, deploy-text-extractor-cdk,]
if: github.event.action != 'closed'
runs-on: ubuntu-22.04
environment:
name: "dev"
env:
ENVIRONMENT_NAME: "dev"
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true

- name: Find PR number
uses: jwalton/gh-find-current-pr@v1
id: findPr
with:
state: open

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-east-1

- name: Deploy Site-Lambda
if: success() && steps.findPr.outputs.number
env:
PR_NUMBER: ${{ steps.findPr.outputs.pr }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
CDK_DEBUG: true
run: |
pushd cdk-eregs
npm install -g aws-cdk@latest @aws-sdk/client-ssm
npm install

API_STACK="cms-eregs-eph-$PR_NUMBER-api"

cdk deploy $API_STACK \
-c environment=${{ env.ENVIRONMENT_NAME }} \
--require-approval never \
--exclusively \
--app "npx ts-node bin/zip-lambdas.ts"
popd

deployment-status-cdk:
needs: [deploy-zip-lambdas-cdk, deploy-text-extractor-cdk, deploy-fr-parser-cdk, deploy-ecfr-parser-cdk]
needs: [deploy-static-asset-cdk,deploy-zip-lambdas-cdk, deploy-text-extractor-cdk, deploy-fr-parser-cdk, deploy-ecfr-parser-cdk, deploy-site-lambda-cdk]
if: always()
runs-on: ubuntu-22.04
environment: "dev"
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/remove-experimental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,29 @@ jobs:
npm install
serverless remove --stage dev${PR}
popd
- name: Destroy PR-Specific Static-Asset Stack
env:
PR_NUMBER: ${{ github.event.number }}
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
CDK_DEBUG: true
ENVIRONMENT_NAME: ${{ env.ENVIRONMENT_NAME }}
run: |
pushd cdk-eregs
npm install -g aws-cdk@latest @aws-sdk/client-ssm
npm install

# Generate the exact stack name for this PR
STACK_NAME="cms-eregs-eph-${PR_NUMBER}-static-assets"

echo "Destroying PR-specific stack: ${STACK_NAME}"
cdk destroy "${STACK_NAME}" \
-c environment=${{ env.ENVIRONMENT_NAME }} \
--force \
--app "npx ts-node bin/zip-lambdas.ts"

echo "Cleanup completed for stack: ${STACK_NAME}"
popd
- name: Destroy PR-Specific Redirect Stack
env:
PR_NUMBER: ${{ github.event.number }}
Expand Down Expand Up @@ -176,6 +199,13 @@ jobs:
--force \
--app "npx ts-node bin/docker-lambdas.ts"

# Destroy api-stack stack
echo "Destroying PR-specific stack: ${ECFR_PARSER_STACK}"
cdk destroy "${API_STACK}" \
-c environment=${{ env.ENVIRONMENT_NAME }} \
--force \
--app "npx ts-node bin/zip-lambdas.ts"

echo "Cleanup completed for all Docker-based stacks"
popd

Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ solution/ui/regulations/dist
solution/Dockerfile
solution/ui/regulations/coverage/
db_backup/
# Specific to CDK Lambda layer generation
cdk-eregs/lib/stacks/layer-output-*/
cdk-eregs/lib/stacks/layer-output-*/**

# Zip files generated during layer creation
*.zip
37 changes: 19 additions & 18 deletions cdk-eregs/bin/cdk-eregs.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
// #!/usr/bin/env node
// import * as cdk from 'aws-cdk-lib';
// import { getParameterValue } from '../utils/parameter-store';
// import { validateEnvironmentContext } from '../config/environment-config';
// import { RedirectApiStack } from '../lib/stacks/redirect-stack';
// import { StageConfig } from '../config/stage-config';
// import { IamPathAspect } from '../lib/aspects/iam-path';
// import { IamPermissionsBoundaryAspect } from '../lib/aspects/iam-permissions-boundary-aspect';
// import { EphemeralRemovalPolicyAspect } from '../lib/aspects/removal-policy-aspect';
// import * as lambda from 'aws-cdk-lib/aws-lambda';
// import { MaintenanceApiStack } from '../lib/stacks/maintainance-stack';
// import { TextExtractorStack } from '../lib/stacks/text-extract-stack';
// import { FrParserStack } from '../lib/stacks/fr-parser-stack';
// import { S3ImportStack } from '../lib/stacks/s3-import';
// import { EcfrParserStack } from '../lib/stacks/ecfr-parser-stack';

// // import { StackFactory } from '../lib/factories/stack-factory';
// // import { getStackConfigs } from '../config/stack-definition';
#!/usr/bin/env node
import * as cdk from 'aws-cdk-lib';
import { getParameterValue } from '../utils/parameter-store';
import { validateEnvironmentContext } from '../config/environment-config';
import { RedirectApiStack } from '../lib/stacks/redirect-stack';
import { StageConfig } from '../config/stage-config';
import { IamPathAspect } from '../lib/aspects/iam-path';
import { IamPermissionsBoundaryAspect } from '../lib/aspects/iam-permissions-boundary-aspect';
import { EphemeralRemovalPolicyAspect } from '../lib/aspects/removal-policy-aspect';
import * as lambda from 'aws-cdk-lib/aws-lambda';
import { MaintenanceApiStack } from '../lib/stacks/maintainance-stack';
import { TextExtractorStack } from '../lib/stacks/text-extract-stack';
import { FrParserStack } from '../lib/stacks/fr-parser-stack';
import { S3ImportStack } from '../lib/stacks/s3-import';
import { EcfrParserStack } from '../lib/stacks/ecfr-parser-stack';
import { StaticAssetsStack } from '../lib/stacks/static-assets-stack';

// import { StackFactory } from '../lib/factories/stack-factory';
// import { getStackConfigs } from '../config/stack-definition';
// async function main() {
// // Initialize CDK App with synthesizer configuration
// // const synthesizerConfigJson = await getParameterValue('/cms/cloud/cdkSynthesizerConfig');
Expand Down
24 changes: 19 additions & 5 deletions cdk-eregs/bin/docker-lambdas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { EphemeralRemovalPolicyAspect } from '../lib/aspects/removal-policy-aspe
import { TextExtractorStack } from '../lib/stacks/text-extract-stack';
import { FrParserStack } from '../lib/stacks/fr-parser-stack';
import { EcfrParserStack } from '../lib/stacks/ecfr-parser-stack';

import { PythonLayerStack} from '../lib/stacks/lambda-layer-stack';
async function main() {
const synthesizerConfigJson = await getParameterValue('/eregulations/cdk_config');
const synthesizerConfig = JSON.parse(synthesizerConfigJson);
Expand Down Expand Up @@ -74,7 +74,21 @@ async function main() {
});
}

// Create Docker-based Lambda stacks
// // Create Docker-based Lambda stacks
// new TextExtractorStack(app, stageConfig.getResourceName('text-extractor'), {
// env,
// lambdaConfig: {
// memorySize: 1024,
// timeout: 900,
// reservedConcurrentExecutions: 10,
// },
// environmentConfig: {
// vpcId,
// logLevel,
// httpUser,
// httpPassword,
// }
// }, stageConfig);
new TextExtractorStack(app, stageConfig.getResourceName('text-extractor'), {
env,
lambdaConfig: {
Expand All @@ -83,13 +97,11 @@ async function main() {
reservedConcurrentExecutions: 10,
},
environmentConfig: {
vpcId,
logLevel,
httpUser,
httpPassword,
}
}, stageConfig);

new FrParserStack(app, stageConfig.getResourceName('fr-parser'), {
env,
lambdaConfig: {
Expand All @@ -115,7 +127,9 @@ async function main() {
httpPassword,
}
}, stageConfig);

const layerStack = new PythonLayerStack(app, stageConfig.getResourceName(`python-layer`), {

}, stageConfig);
await applyGlobalAspects(app, stageConfig);

app.synth();
Expand Down
Loading
Loading