diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 9120715..be0955a 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -1,43 +1,47 @@ -# name: AWS Service CI/CD +name: AWS CDK deploy AI Service API -# on: -# push: -# branches: ['main', 'master'] -# pull_request: -# branches: ['main', 'master'] +on: + push: + branches: [master, main, dev/*, feature/*, release/*, staging/*, prod/*, qa] + pull_request: + branches: [master, main, dev/*, feature/*, release/*, staging/*, prod/*, qa] -# env: -# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} -# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} -# AWS_DEFAULT_REGION: "us-east-1" +env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: "us-east-1" -# jobs: -# build: -# runs-on: ubuntu-latest -# steps: -# - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." -# - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" -# - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." -# - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." -# - uses: actions/checkout@v3 -# - name: Set up Python 3.9 -# uses: actions/setup-python@v4 -# with: -# python-version: "3.9" -# - name: Set up Node -# uses: actions/setup-node@v3 -# with: -# node-version: "16" +jobs: + build: + runs-on: ubuntu-latest + steps: + - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" + - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." + - uses: actions/checkout@v3 + - name: Set up Python 3.9 + uses: actions/setup-python@v4 + with: + python-version: "3.9" + - name: Set up Node + uses: actions/setup-node@v3 + with: + node-version: "16" -# - name: Install Python dependencies and CDK -# run: | -# python -m pip install --upgrade pip -# # install your Python dependencies here -# npm install -g aws-cdk -# pip install -r requirements.txt -# pip install -r requirements-dev.txt + - name: Install Python dependencies and CDK + run: | + python -m pip install --upgrade pip + # install your Python dependencies here + npm install -g aws-cdk + pip install -r requirements.txt -# # - name: Deploy to AWS -# # run: cdk deploy --require-approval=never --no-asset-metadata --force -# - name: Destroy stack -# run: cdk destroy --require-approval=never --no-asset-metadata --force \ No newline at end of file + - name: Deploy to AWS + run: cdk deploy ApiLambdaBedrockStack --require-approval=never --no-asset-metadata --force + env: + AWS_ACCESS_KEY_ID: ${{ env.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ env.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: ${{ env.AWS_DEFAULT_REGION }} + + # - name: Destroy stack + # run: cdk destroy --require-approval=never --no-asset-metadata --force \ No newline at end of file diff --git a/.github/workflows/run_python_test.yml b/.github/workflows/run_python_test.yml index 824dc42..f3ce873 100644 --- a/.github/workflows/run_python_test.yml +++ b/.github/workflows/run_python_test.yml @@ -27,10 +27,10 @@ jobs: pip install -U coverage if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with pylint - run: | - pylint apps/home - continue-on-error: true + # - name: Lint with pylint + # run: | + # pylint apps/home + # continue-on-error: true - name: Test with pytest run: | # pytest -v -s diff --git a/.gitignore b/.gitignore index 37833f8..9d5425f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ __pycache__ # CDK asset staging directory .cdk.staging cdk.out +venv +./venv diff --git a/template.yaml b/template.yaml index beeea06..afbf41f 100644 --- a/template.yaml +++ b/template.yaml @@ -9,7 +9,7 @@ Resources: CompatibleRuntimes: - python3.10 Metadata: - aws:cdk:path: ApigwLambdaBedrockStack/Boto3Layer/Resource + aws:cdk:path: ApiLambdaBedrockStack/Boto3Layer/Resource aws:asset:path: asset.71935fa708b6f595452cd5b66b67e4897d4653a82adc544d0c2a2c165c8f1298.zip aws:asset:is-bundled: false aws:asset:property: Content @@ -31,7 +31,7 @@ Resources: Roles: - Ref: MyFunctionServiceRole3C357FF2 Metadata: - aws:cdk:path: ApigwLambdaBedrockStack/InvokeModelPolicy/Resource + aws:cdk:path: ApiLambdaBedrockStack/InvokeModelPolicy/Resource MyFunctionServiceRole3C357FF2: Type: AWS::IAM::Role Properties: @@ -49,14 +49,14 @@ Resources: - Ref: AWS::Partition - :iam::aws:policy/service-role/AWSLambdaBasicExecutionRole Metadata: - aws:cdk:path: ApigwLambdaBedrockStack/MyFunction/ServiceRole/Resource + aws:cdk:path: ApiLambdaBedrockStack/MyFunction/ServiceRole/Resource MyFunction3BAA72D1: Type: AWS::Lambda::Function Properties: Code: S3Bucket: Fn::Sub: cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region} - S3Key: 46c24f26abc575f4718a49ec1a295357c936d89c73d1f1f3f05d7d686940a2aa.zip + S3Key: 29069b9cd3de018f1196a1ccde2785ab561f68630b89c6e2f3d3a2fe6290b764.zip Role: Fn::GetAtt: - MyFunctionServiceRole3C357FF2 @@ -69,8 +69,8 @@ Resources: DependsOn: - MyFunctionServiceRole3C357FF2 Metadata: - aws:cdk:path: ApigwLambdaBedrockStack/MyFunction/Resource - aws:asset:path: asset.46c24f26abc575f4718a49ec1a295357c936d89c73d1f1f3f05d7d686940a2aa + aws:cdk:path: ApiLambdaBedrockStack/MyFunction/Resource + aws:asset:path: asset.29069b9cd3de018f1196a1ccde2785ab561f68630b89c6e2f3d3a2fe6290b764 aws:asset:is-bundled: false aws:asset:property: Code ServerlessLandGenAI3932CB69: @@ -78,8 +78,8 @@ Resources: Properties: Name: ServerlessLandGenAI Metadata: - aws:cdk:path: ApigwLambdaBedrockStack/ServerlessLandGenAI/Resource - ServerlessLandGenAIDeploymentAB06D0199bd18db26d65736d1507b2c05681161e: + aws:cdk:path: ApiLambdaBedrockStack/ServerlessLandGenAI/Resource + ServerlessLandGenAIDeploymentAB06D01945513ae789644cc31803ae8f429f99bd: Type: AWS::ApiGateway::Deployment Properties: RestApiId: @@ -89,17 +89,17 @@ Resources: - ServerlessLandGenAItextgenPOSTD9CF9A37 - ServerlessLandGenAItextgen7DB7CAB2 Metadata: - aws:cdk:path: ApigwLambdaBedrockStack/ServerlessLandGenAI/Deployment/Resource + aws:cdk:path: ApiLambdaBedrockStack/ServerlessLandGenAI/Deployment/Resource ServerlessLandGenAIDeploymentStageprodD2F4F2E0: Type: AWS::ApiGateway::Stage Properties: RestApiId: Ref: ServerlessLandGenAI3932CB69 DeploymentId: - Ref: ServerlessLandGenAIDeploymentAB06D0199bd18db26d65736d1507b2c05681161e + Ref: ServerlessLandGenAIDeploymentAB06D01945513ae789644cc31803ae8f429f99bd StageName: prod Metadata: - aws:cdk:path: ApigwLambdaBedrockStack/ServerlessLandGenAI/DeploymentStage.prod/Resource + aws:cdk:path: ApiLambdaBedrockStack/ServerlessLandGenAI/DeploymentStage.prod/Resource ServerlessLandGenAItextgen7DB7CAB2: Type: AWS::ApiGateway::Resource Properties: @@ -111,8 +111,8 @@ Resources: RestApiId: Ref: ServerlessLandGenAI3932CB69 Metadata: - aws:cdk:path: ApigwLambdaBedrockStack/ServerlessLandGenAI/Default/text_gen/Resource - ServerlessLandGenAItextgenPOSTApiPermissionApigwLambdaBedrockStackServerlessLandGenAIF613D839POSTtextgenCAEF386D: + aws:cdk:path: ApiLambdaBedrockStack/ServerlessLandGenAI/Default/text_gen/Resource + ServerlessLandGenAItextgenPOSTApiPermissionApiLambdaBedrockStackServerlessLandGenAIABB29318POSTtextgen8EBA4F6E: Type: AWS::Lambda::Permission Properties: Action: lambda:InvokeFunction @@ -136,8 +136,8 @@ Resources: - Ref: ServerlessLandGenAIDeploymentStageprodD2F4F2E0 - /POST/text_gen Metadata: - aws:cdk:path: ApigwLambdaBedrockStack/ServerlessLandGenAI/Default/text_gen/POST/ApiPermission.ApigwLambdaBedrockStackServerlessLandGenAIF613D839.POST..text_gen - ServerlessLandGenAItextgenPOSTApiPermissionTestApigwLambdaBedrockStackServerlessLandGenAIF613D839POSTtextgen7F67980E: + aws:cdk:path: ApiLambdaBedrockStack/ServerlessLandGenAI/Default/text_gen/POST/ApiPermission.ApiLambdaBedrockStackServerlessLandGenAIABB29318.POST..text_gen + ServerlessLandGenAItextgenPOSTApiPermissionTestApiLambdaBedrockStackServerlessLandGenAIABB29318POSTtextgen4267402C: Type: AWS::Lambda::Permission Properties: Action: lambda:InvokeFunction @@ -159,7 +159,7 @@ Resources: - Ref: ServerlessLandGenAI3932CB69 - /test-invoke-stage/POST/text_gen Metadata: - aws:cdk:path: ApigwLambdaBedrockStack/ServerlessLandGenAI/Default/text_gen/POST/ApiPermission.Test.ApigwLambdaBedrockStackServerlessLandGenAIF613D839.POST..text_gen + aws:cdk:path: ApiLambdaBedrockStack/ServerlessLandGenAI/Default/text_gen/POST/ApiPermission.Test.ApiLambdaBedrockStackServerlessLandGenAIABB29318.POST..text_gen ServerlessLandGenAItextgenPOSTD9CF9A37: Type: AWS::ApiGateway::Method Properties: @@ -185,13 +185,13 @@ Resources: - Arn - /invocations Metadata: - aws:cdk:path: ApigwLambdaBedrockStack/ServerlessLandGenAI/Default/text_gen/POST/Resource + aws:cdk:path: ApiLambdaBedrockStack/ServerlessLandGenAI/Default/text_gen/POST/Resource CDKMetadata: Type: AWS::CDK::Metadata Properties: Analytics: v2:deflate64:H4sIAAAAAAAA/1WPQW+DMAyFf0vvIdvgsmvLtNOmISrtWrnBpS6QIOwIIcR/nxKYVE7ve3ae7aT6PdWvBxg5MVWTtHTV81nANApGvswtdNcK9PwFEw6/ODA5q/Kb3flPb41sjWcucOiIw5NFcXYBZhTWxyCKM33ypkE5AaMi6PRcuJbMFIMrla7FYIMuCnqqQXCESc8lshx7is0NP7Bv3dShlVB9cmeBOo5ZoUR2fjAY9/6bbdDK3yh3V4XSSsui4s0hT7behX689F528fxmc2crkvjvYpK7sy+Zfkt1engwUTJ4K9ShLlf9AyBqMtqCAQAA Metadata: - aws:cdk:path: ApigwLambdaBedrockStack/CDKMetadata/Default + aws:cdk:path: ApiLambdaBedrockStack/CDKMetadata/Default Condition: CDKMetadataAvailable Outputs: ServerlessLandGenAIEndpoint41934CF9: