aws-solutions / content-analysis-on-aws

As of August 30, 2023, this AWS Solution is no longer available. Existing deployments will continue to run. The functionality provided by Content Analysis on AWS will be superseded with functionality in Media2Cloud on AWS and Content Localization on AWS. We encourage you to explore these solutions.
https://aws.amazon.com/solutions/implementations/aws-content-analysis/
Apache License 2.0
96 stars 47 forks source link

WebsiteDeployHelper - Runtime Python3.6 #74

Closed WulfenSan closed 1 year ago

WulfenSan commented 2 years ago

Describe the bug WebsiteDeployHelper is failing to create. Embedded stack arn:aws:cloudformation:us-east-1:xxxxxxxx:stack/ContAnalyz-WebStack-NAV0C7BT3YE7/8ea78950-18f2-11ed-a065-0e987b47ea9f was not successfully created: The following resource(s) failed to create: [WebsiteDeployHelper].

Resource handler returned message: "The runtime parameter of python3.6 is no longer supported for creating or updating AWS Lambda functions. We recommend you use the new runtime (python3.9) while creating or updating functions. (Service: Lambda, Status Code: 400, Request ID: 9c7293a7-99d7-4e54-992c-0a00d3fc612b)" (RequestToken: 88e80d66-96e9-b03f-ce72-c97a67334ed9, HandlerErrorCode: InvalidRequest)

To Reproduce Create stack with aws-content-analysis template.

Expected behavior Creation of WebStack resource.

Please complete the following information about the solution:

kyyyyylehead commented 2 years ago

Hey @WulfenSan ,

My team was trying to implement the content analysis and we ran into the same issue as you, not sure if you ever figured this out on your own but I'll leave the solution here for you and anyone else that may come across this thread.

So stack creation follows the template of aws-content-analysis.yaml. Everything works fine until the WebStack, and if you look at aws-content-analysis-web.yaml here you see where we get the runtime error.

Some of the source code is provided in this repo but if you look through the templates you'll see that everything is actually getting built by pulling from an S3 bucket called rodeolabz. We need to fix some of theses file so we'll be creating our own versions.

So steps to fix this are as follows:

  1. Create your own S3 bucket & directory for templates (I called mine "my-templates/aws-content-analysis")
  2. Go to this link to download the rodeolabz websitehelper.zip
  3. Go to this link for the web template and open it.
  4. Change line 50 and line 291 to Runtime: python3.9, change the WebsiteDeployHelper Properties to reference your new websitehelper.zip like so
    Properties:
      Code:
        S3Bucket:  "my-templates"
        S3Key:
          !Join [
              "/",
            [
              "aws-content-analysis",
              "websitehelper.zip",
            ],
          ]
  5. Upload both files to your S3 bucket/directory
  6. Copy aws-content-analysis.yaml somewhere and save it as a .template
  7. Go to AWS CloudFormation>Designer. Open aws-content-analysis.template. Add some mappings that will point to your personal template bucket. My mappings look like this
    SourceCode:
      GlobalS3Bucket: "rodeolabz-us-east-1"
      TemplateKeyPrefix: "aws-content-analysis/v2.0.0"
      RegionalS3Bucket: "rodeolabz-us-east-1"
      CodeKeyPrefix: "aws-content-analysis/v2.0.0"
      Version: v2.0.0
      PersonalS3Bucket: "my-templates"
      WebStackPrefix: "aws-content-analysis"
  8. Still in the editor, where you build your WebStack url point to your new template bucket instead of rodeolabz (only for WebStack). Like this
      TemplateURL: !Join
        - ""
        - - "https://"
          - !FindInMap
            - Application
            - SourceCode
            - PersonalS3Bucket
          - ".s3.amazonaws.com/"
          - !FindInMap
            - Application
            - SourceCode
            - WebStackPrefix
          - "aws-content-analysis-web.template"

And that's it! Now you bypass the python runtime error and you can continue through the README to finish setting up the content analysis website. If I missed anything let me know, it might be from website_helper.py in the zip file.

WulfenSan commented 2 years ago

Thanks for that, @kyyyyylehead! I was going through those steps, and after some additional work noticed that the base template had a new version. Ran it just to confirm, and it looks like it's now been fixed. But I definitely appreciate the thorough workaround effort!