awslabs / amplify-video

An open source Category Plugin for the AWS Amplify-CLI that makes it easy to deploy live and file based streaming video services and integrate them into your Amplify applications.
https://www.npmjs.com/package/amplify-category-video
Apache License 2.0
267 stars 56 forks source link

Amplify video fails on push with error for bad indentation #312

Closed shamikatamazon closed 2 years ago

shamikatamazon commented 2 years ago

Describe the bug amplify push fails with error

bad indentation of a mapping entry (183:17)

 180 |         pS3: !Ref pS3
 181 |         pSourceFolder: !Ref pSourceFolder
 182 |         pFunctionHash: "30687636766b52416c4d"
 183 |                 pFunctionName:
-----------------------^
 184 |           !If
 185 |             - HasEnvironmentParameter
An error occurred during the push operation: bad indentation of a mapping entry (183:17)

 180 |         pS3: !Ref pS3
 181 |         pSourceFolder: !Ref pSourceFolder
 182 |         pFunctionHash: "30687636766b52416c4d"
 183 |                 pFunctionName:
-----------------------^
 184 |           !If
 185 |             - HasEnvironmentParameter

A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

Admin:~/environment/amplify-video (master) $ amplify video add
? Please select from one of the below mentioned services: Video-On-Demand
? Provide a friendly name for your resource to be used as a label for this category in the project: bug312
? Select a system-provided encoding template, specify an already-created template name:  Default HLS Adaptive Bitrate
? Do you want to get notifications on the video processing job? Yes
? Do you want a custom function executed for notifications? Yes
? Is this a production enviroment? No
? Do you want Amplify to create a new GraphQL API to manage your videos? (Beta) No
✔ All resources built.
Admin:~/environment/amplify-video (master) $ amplify push

Expected behavior Amplify push succeeds

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

shamikatamazon commented 2 years ago

While fixing this bug, I came across another one which was a part of the same commit

⠴ Updating resources in the cloud. This may take a few minutes...

CREATE_FAILED      rSnsInvokeLambdaSetup AWS::CloudFormation::Stack Mon Sep 27 2021 22:19:44 GMT+0000 (Coordinated Universal Time) Parameters: [env] do not exist in the template
CREATE_IN_PROGRESS rMediaConvertTemplate AWS::CloudFormation::Stack Mon Sep 27 2021 22:19:44 GMT+0000 (Coordinated Universal Time) Resource creation Initiated                   
CREATE_IN_PROGRESS rS3InputBucket        AWS::CloudFormation::Stack Mon Sep 27 2021 22:19:44 GMT+0000 (Coordinated Universal Time) Resource creation Initiated                   
CREATE_IN_PROGRESS rS3OutputBucket       AWS::CloudFormation::Stack Mon Sep 27 2021 22:19:45 GMT+0000 (Coordinated Universal Time) Resource creation Initiated                   
⠧ Updating resources in the cloud. This may take a few minutes...

Fixing this as a part of this commit also

cloobfm commented 2 years ago

Wanted to pass this on as the CREATE_FAILED rSnsInvokeLambdaSetup issue is still not corrected. Spent much time trying to figure this is out despite using the latest amplify-category-video merge. The issue I believe is that the template file SnsSetup.template.ejs is actually missing the references to [GraphQLAPIId, GraphQLEndpoint] like they exist in the other template files for InputTriggerLambda.template & OutputTriggerLambda.template. Need to add them back in as below. I tested this out and finally was able to get cloud resources to deploy properly with SNS on.

Also worthy of note, when amplify push'ing each module by one at a time, which I used to troubleshoot this issue (Auth / API / Video), the video resources are not deployed properly (S3 buckets, particularly) unless you do an amplify push for the whole stack.

Parameters:
env:
Type: String
    Description: The environment name. e.g. Dev, Test, or Production.
    Default: NONE
  pS3:
    Type: String
    Description: Store template and lambda package
    AllowedPattern: "[a-zA-Z][a-zA-Z0-9-_]*"
    Default: amazonbooth
  pSourceFolder:
    Type: String
    Description: Store template and lambda package
    AllowedPattern: "[a-zA-Z][a-zA-Z0-9-_]*"
    Default: vod-helpers
  pFunctionName:
    Type: String
    Description: Name of function
    Default: arn-default
  pFunctionHash:
    Type: String
    Description: FunctionHash
    Default: default
  pSnsTopicName:
    Type: String
    Description: FunctionHash
    Default: default
  GraphQLAPIId:
    Type: String
    Description: API ID
    Default: NONE
  GraphQLEndpoint:
    Type: String
    Description: API Endpoint URL
    Default: NONE

and

rMediaconvertStatusLambda:
    Type: AWS::Lambda::Function
    Properties:
      FunctionName: !Ref pFunctionName
      Description: Invoked on MediaConvert status events 
      Handler: index.handler
      Role: !GetAtt rMediaconvertStatusLambdaRole.Arn
      Runtime: nodejs14.x
      Timeout: 30
      Environment:
        Variables:
          ENV: !Ref env
          GRAPHQLID: !Ref GraphQLAPIId
          GRAPHQLEP: !Ref GraphQLEndpoint
      Code:
        S3Bucket: !Ref pS3
        S3Key: !Sub
          - vod-helpers/MediaConvertStatusLambda-${hash}.zip
          - { hash: !Ref pFunctionHash }

While fixing this bug, I came across another one which was a part of the same commit

⠴ Updating resources in the cloud. This may take a few minutes...

CREATE_FAILED      rSnsInvokeLambdaSetup AWS::CloudFormation::Stack Mon Sep 27 2021 22:19:44 GMT+0000 (Coordinated Universal Time) Parameters: [env] do not exist in the template
CREATE_IN_PROGRESS rMediaConvertTemplate AWS::CloudFormation::Stack Mon Sep 27 2021 22:19:44 GMT+0000 (Coordinated Universal Time) Resource creation Initiated                   
CREATE_IN_PROGRESS rS3InputBucket        AWS::CloudFormation::Stack Mon Sep 27 2021 22:19:44 GMT+0000 (Coordinated Universal Time) Resource creation Initiated                   
CREATE_IN_PROGRESS rS3OutputBucket       AWS::CloudFormation::Stack Mon Sep 27 2021 22:19:45 GMT+0000 (Coordinated Universal Time) Resource creation Initiated                   
⠧ Updating resources in the cloud. This may take a few minutes...

Fixing this as a part of this commit also

wizage commented 2 years ago

This is fixed in #324

Deploying it soon