ised-isde-canada / cbmdsp-cp-sp-overall-architecture

1 stars 1 forks source link

Testing upload-portal-api and client #46

Open obriensystems opened 2 years ago

obriensystems commented 2 years ago

api first

biometric:presigned-url-testing michaelobrien$ make -C upload-portal-api build Starting Build use cache Starting Build inside a container Cache is invalid, running build and copying resources to function build definition of 1d299b87-0325-444f-af97-b4856a9c4d5e Building codeuri: /Users/michaelobrien/wse_github/ised-isde-canada/cbmdsp-cp-sp-overall-architecture/presigned-url-testing/upload-portal-api/lambda runtime: python3.8 metadata: {} functions: ['UploadPortalFunction']

Fetching public.ecr.aws/sam/build-python3.8:latest Docker container image.................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................... Mounting /Users/michaelobrien/wse_github/ised-isde-canada/cbmdsp-cp-sp-overall-architecture/presigned-url-testing/upload-portal-api/lambda as /tmp/samcli/source:ro,delegated inside runtime container

Build Succeeded

Built Artifacts : build Built Template : build/template.yaml

Commands you can use next

[] Invoke Function: sam local invoke -t build/template.yaml [] Deploy: sam deploy --guided --template-file build/template.yaml

Running PythonPipBuilder:ResolveDependencies Running PythonPipBuilder:CopySource

SAM CLI update available (1.33.0); (1.26.0 installed) To download: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html

obriensystems commented 2 years ago

deploy api

biometric:presigned-url-testing michaelobrien$ cfn-cli stack deploy === Unhandled exception === Please report this issue to the team. Issue tracker: github.com/aws-cloudformation/cloudformation-cli/issues Please include this information: Traceback (most recent call last): File "/usr/local/lib/python3.9/site-packages/rpdk/core/cli.py", line 83, in main init_setup_subparser(subparsers, parents) File "/usr/local/lib/python3.9/site-packages/rpdk/core/init.py", line 168, in setup_subparser language_setup_subparser()(language_subparsers, [base_subparser]) File "/usr/local/lib/python3.9/site-packages/pkg_resources/init.py", line 2449, in load self.require(*args, **kwargs) File "/usr/local/lib/python3.9/site-packages/pkg_resources/init.py", line 2472, in require items = working_set.resolve(reqs, env, installer, extras=self.extras) File "/usr/local/lib/python3.9/site-packages/pkg_resources/init.py", line 777, in resolve raise VersionConflict(dist, req).with_context(dependent_req) pkg_resources.ContextualVersionConflict: (PyYAML 5.3.1 (/Users/michaelobrien/Library/Python/3.9/lib/python/site-packages), Requirement.parse('pyyaml>=5.4; python_version != "3.4" and python_version != "3.5"'), {'cfn-lint'}) biometric:presigned-url-testing michaelobrien$ sam deploy --guided Error: Template file not found at /Users/michaelobrien/wse_github/ised-isde-canada/cbmdsp-cp-sp-overall-architecture/presigned-url-testing/template.yml biometric:presigned-url-testing michaelobrien$ cd README.md cfn-cli.yaml upload-client/ upload-js-client/ upload-portal-api/ biometric:presigned-url-testing michaelobrien$ cd upload-portal-api/ biometric:upload-portal-api michaelobrien$ sam deploy --guided

Configuring SAM deploy

Looking for config file [samconfig.toml] :  Not found

Setting default arguments for 'sam deploy'
=========================================
Stack Name [sam-app]: sam-upload-portal-api
AWS Region [us-east-1]: ca-central-1
Parameter UploadPortalBucket []: ised-upload-portal
Parameter Application []: param
Parameter Environment [dev]: 
#Shows you resources changes to be deployed and require a 'Y' to initiate deploy
Confirm changes before deploy [y/N]: y
#SAM needs permission to be able to create roles to connect to the resources in your template
Allow SAM CLI IAM role creation [Y/n]: y
Save arguments to configuration file [Y/n]: y
SAM configuration file [samconfig.toml]: 
SAM configuration environment [default]: 

Looking for resources needed for deployment: Found!

    Managed S3 bucket: aws-sam-cli-managed-default-samclisourcebucket-vbqhref6p1rt
    A different default S3 bucket can be set in samconfig.toml

Saved arguments to config file
Running 'sam deploy' for future deployments will use the parameters saved above.
The above parameters can be changed by modifying samconfig.toml
Learn more about samconfig.toml syntax at 
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-config.html

Uploading to sam-upload-portal-api/246051b3bb963164a04ec13cd6932ff5 1230 / 1230 (100.00%)

Deploying with following values
===============================
Stack name                   : sam-upload-portal-api
Region                       : ca-central-1
Confirm changeset            : True
Deployment s3 bucket         : aws-sam-cli-managed-default-samclisourcebucket-vbqhref6p1rt
Capabilities                 : ["CAPABILITY_IAM"]
Parameter overrides          : {"UploadPortalBucket": "ised-upload-portal", "Application": "param", "Environment": "dev"}
Signing Profiles             : {}

Initiating deployment

Uploading to sam-upload-portal-api/3f6a4c54a67c64489f7118d02acc5742.template 3622 / 3622 (100.00%)

Waiting for changeset to be created..

CloudFormation stack changeset

Operation LogicalResourceId ResourceType Replacement

Changeset created successfully. arn:aws:cloudformation:ca-central-1:453279094200:changeSet/samcli-deploy1634926924/05a8e5c3-e34f-46c6-9897-a834d1cefb42

Previewing CloudFormation changeset before deployment

Deploy this changeset? [y/N]: y

2021-10-22 14:22:18 - Waiting for stack create/update to complete

CloudFormation events from changeset

ResourceStatus ResourceType LogicalResourceId ResourceStatusReason

CREATE_IN_PROGRESS AWS::IAM::Role UploadPortalFunctionRole Resource creation Initiated
CREATE_IN_PROGRESS AWS::ApiGateway::RestApi RestApi -
CREATE_IN_PROGRESS AWS::IAM::Role UploadPortalFunctionRole -
CREATE_IN_PROGRESS AWS::ApiGateway::RestApi RestApi Resource creation Initiated
CREATE_COMPLETE AWS::ApiGateway::RestApi RestApi -
CREATE_IN_PROGRESS AWS::ApiGateway::Resource ProxyResource -
CREATE_IN_PROGRESS AWS::ApiGateway::Resource ProxyResource Resource creation Initiated
CREATE_COMPLETE AWS::ApiGateway::Resource ProxyResource -
CREATE_COMPLETE AWS::IAM::Role UploadPortalFunctionRole -
CREATE_IN_PROGRESS AWS::Lambda::Function UploadPortalFunction -
CREATE_IN_PROGRESS AWS::Lambda::Function UploadPortalFunction Resource creation Initiated
CREATE_COMPLETE AWS::Lambda::Function UploadPortalFunction -
CREATE_IN_PROGRESS AWS::ApiGateway::Method ProxyResourceANY -
CREATE_IN_PROGRESS AWS::Lambda::Permission UploadPortalLambdaPermissions Resource creation Initiated
CREATE_IN_PROGRESS AWS::Lambda::Permission UploadPortalLambdaPermissions -
CREATE_IN_PROGRESS AWS::ApiGateway::Method ProxyResourceANY Resource creation Initiated
CREATE_COMPLETE AWS::ApiGateway::Method ProxyResourceANY -
CREATE_IN_PROGRESS AWS::ApiGateway::Deployment ApiDeployment -
CREATE_COMPLETE AWS::ApiGateway::Deployment ApiDeployment -
CREATE_IN_PROGRESS AWS::ApiGateway::Deployment ApiDeployment Resource creation Initiated
CREATE_IN_PROGRESS AWS::ApiGateway::Stage ApiStage -
CREATE_IN_PROGRESS AWS::ApiGateway::Stage ApiStage Resource creation Initiated
CREATE_COMPLETE AWS::ApiGateway::Stage ApiStage -
CREATE_COMPLETE AWS::Lambda::Permission UploadPortalLambdaPermissions -
CREATE_COMPLETE AWS::CloudFormation::Stack sam-upload-portal-api -

CloudFormation outputs from deployed stack

Outputs

Key UploadPortalApi
Description API Gateway endpoint URL for Upload Portal
Value https://4wnzzzf0u1.execute-api.ca-central-1.amazonaws.com/dev/

Key ApiArn
Description -
Value arn:aws:apigateway:ca-central-1::/restapis/4wnzzzf0u1/stages/dev

Successfully created/updated stack - sam-upload-portal-api in ca-central-1

obriensystems commented 2 years ago

Issue is my cfn is not setup correctly - aws sam fails to install the library aws_lambda_powertools

Test Event Name (unsaved)

Response { "errorMessage": "Unable to import module 'app': No module named 'aws_lambda_powertools'", "errorType": "Runtime.ImportModuleError", "stackTrace": [] }

Function Logs START RequestId: 1b12f38e-cc16-45b5-b82e-6a3e0fb930f5 Version: $LATEST [ERROR] Runtime.ImportModuleError: Unable to import module 'app': No module named 'aws_lambda_powertools' Traceback (most recent call last):END RequestId: 1b12f38e-cc16-45b5-b82e-6a3e0fb930f5 REPORT RequestId: 1b12f38e-cc16-45b5-b82e-6a3e0fb930f5 Duration: 2.70 ms Billed Duration: 3 ms Memory Size: 128 MB Max Memory Used: 51 MB Init Duration: 330.93 ms

Request ID 1b12f38e-cc16-45b5-b82e-6a3e0fb930f5