localstack / localstack

💻 A fully functional local AWS cloud stack. Develop and test your cloud & Serverless apps offline
https://localstack.cloud
Other
55.39k stars 3.96k forks source link

Appsync - VTL - String Concatenation not supported #2714

Closed ngouass closed 4 years ago

ngouass commented 4 years ago

Type of request: This is a ...

[x] bug report [ ] feature request

Detailed description

VTL request containing an expression evaluated to String Concatenation does not work.

Query

mutation createShop {
            createShop(shop: { shopName: "Apple" } ) {
              shopName
            }
          }

VTL Template (Works when deploy to Appsync on AWS services)

{
  "version" : "2018-05-29",
  "operation" : "PutItem",
  "key" : {
    "PK": $util.dynamodb.toDynamoDBJson("SHOP#${ctx.args.shop.shopName}"),
    "SK": $util.dynamodb.toDynamoDBJson("PROFILE#$ctx.args.shop.shopName")
  },
  "attributeValues" : { "shopName": { "S": "Apple" }}
}

Expected behavior

Item stored in dynamodb

{
            "PK": {
                "S": "SHOP#Apple"
            },
            "SK": {
                "S": "PROFILE#Apple"
            },
            "shopName": {
                "S": "Apple"
            }
        }

Actual behavior

Item stored in dynamodb

{
            "PK": {
                "S": "SHOP#${ctx.args.shop.shopName}"
            },
            "SK": {
                "S": "PROFILE#$ctx.args.shop.shopName"
            },
            "shopName": {
                "S": "Apple"
            }
        }

Steps to reproduce

Command used to start LocalStack

docker-compose

version: '2.1'

services:
  localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main}"
    image: localstack/localstack
    ports:
      - "4566-4700:4566-4700"
      - "443:443"
      - "${PORT_WEB_UI-8080}:${PORT_WEB_UI-8080}"
    environment:
      - SERVICES=serverless,cloudformation,dynamodb,iam,s3,appsync,edge
      - DEBUG=1
      - DATA_DIR=${DATA_DIR- }
      - PORT_WEB_UI=${PORT_WEB_UI- }
      - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR- }
      - KINESIS_ERROR_PROBABILITY=${KINESIS_ERROR_PROBABILITY- }
      - DOCKER_HOST=unix:///var/run/docker.sock
      - HOST_TMP_FOLDER=${TMPDIR}
      - LOCALSTACK_API_KEY=${LOCALSTACK_API_KEY}
    volumes:
      - "${TMPDIR:-/tmp/localstack}:/tmp/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"

Client code (AWS SDK code snippet, or sequence of "awslocal" commands)

...

ngouass commented 4 years ago

Hi @whummer,

I just tested and found that your commit fixed the issue for template: "SHOP#${ctx.args.shop.shopName}". Are you planning to also add the support for "SHOP#$ctx.args.shop.shopName" ?

Thanks.

whummer commented 4 years ago

Thanks for the update @ngouass . This should be fixed in #2719 - can you please give it another try with the latest version of the Docker image? Please report here if the problem persists. Thanks

ngouass commented 4 years ago

Hello, the service Appsync does not start anymore.

localstack_main | Waiting for all LocalStack services to be ready
localstack_main | 2020-07-13 19:36:36,433 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
localstack_main | 2020-07-13 19:36:36,441 INFO supervisord started with pid 14
localstack_main | 2020-07-13 19:36:37,452 INFO spawned: 'dashboard' with pid 20
localstack_main | 2020-07-13 19:36:37,456 INFO spawned: 'infra' with pid 21
localstack_main | 2020-07-13 19:36:37,464 INFO success: dashboard entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
localstack_main | 2020-07-13 19:36:37,465 INFO exited: dashboard (exit status 0; expected)
localstack_main | (. .venv/bin/activate; exec bin/localstack start --host)
localstack_main | 2020-07-13 19:36:38,555 INFO success: infra entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
localstack_main | LocalStack version: 0.11.3
localstack_main | Starting local dev environment. CTRL-C to quit.
localstack_main | 2020-07-13T19:36:38:DEBUG:bootstrap.py: Loading plugins - scope "commands", module "localstack_ext": <function register_localstack_commands at 0x7fa9af0315e0>
localstack_main | 2020-07-13T19:36:38:DEBUG:bootstrap.py: Loading plugins - scope "services", module "localstack_ext": <function register_localstack_plugins at 0x7fa9af3ed040>
localstack_main | Waiting for all LocalStack services to be ready
localstack_main | Waiting for all LocalStack services to be ready
localstack_main | Waiting for all LocalStack services to be ready
localstack_main | Waiting for all LocalStack services to be ready
localstack_main | 2020-07-13T19:37:05:INFO:localstack_ext.bootstrap.licensing: Successfully activated API key

I isolated this log

localstack_main | cannot import name 'VelocityInput' from 'localstack.utils.aws.aws_stack' (/opt/code/localstack/localstack/utils/aws/aws_stack.py)

And Appsync service didn't start

localstack_main | Waiting for all LocalStack services to be ready
localstack_main | 2020-07-13T19:37:11:DEBUG:bootstrap.py: Loading plugins - scope "services", module "localstack": <function register_localstack_plugins at 0x7fa9af3e4dc0>
localstack_main | 2020-07-13T19:37:11:DEBUG:bootstrap.py: Plugin loading took 32.71779990196228 sec
localstack_main | Starting DNS servers (tcp/udp port 53 on 0.0.0.0)...
localstack_main | Starting edge router (http port 4566)...
localstack_main | Starting edge router (https port 443)...
localstack_main | Starting mock API Gateway service on http ports 443 (recommended) and 4567 (deprecated)...
localstack_main | Starting mock CloudFormation service in http ports 443 (recommended) and 4581 (deprecated)...
localstack_main | Starting mock DynamoDB service in http ports 443 (recommended) and 4569 (deprecated)...
localstack_main | Starting mock IAM service on http ports 443 (recommended) and 4593 (deprecated)...
localstack_main | Starting mock STS service on http ports 443 (recommended) and 4592 (deprecated)...
localstack_main | Starting mock Lambda service on http ports 443 (recommended) and 4574 (deprecated)...
localstack_main | Starting mock CloudWatch Logs service on http ports 443 (recommended) and 4586 (deprecated)...
localstack_main | Starting mock S3 service on http ports 443 (recommended) and 4572 (deprecated)...
localstack_main | Running on 0.0.0.0:4566 over https (CTRL + C to quit)
localstack_main | 2020-07-13T19:37:13:INFO:localstack.multiserver: Starting multi API server process on port 45435
localstack_main | Running on 0.0.0.0:443 over https (CTRL + C to quit)
localstack_main | Running on 0.0.0.0:45435 over http (CTRL + C to quit)
localstack_main | Running on 0.0.0.0:4567 over http (CTRL + C to quit)
localstack_main | 2020-07-13 19:37:13,538:API:  * Running on http://0.0.0.0:56653/ (Press CTRL+C to quit)
localstack_main | 2020-07-13 19:37:13,538:API:  * Running on http://0.0.0.0:56653/ (Press CTRL+C to quit)
localstack_main | 2020-07-13 19:37:13,538:API:  * Running on http://0.0.0.0:56653/ (Press CTRL+C to quit)
localstack_main | Running on 0.0.0.0:4581 over http (CTRL + C to quit)
localstack_main | Running on 0.0.0.0:4569 over http (CTRL + C to quit)
localstack_main | Running on 0.0.0.0:4593 over http (CTRL + C to quit)
localstack_main | 2020-07-13 19:37:13,787:API:  * Running on http://0.0.0.0:50259/ (Press CTRL+C to quit)
localstack_main | 2020-07-13 19:37:13,787:API:  * Running on http://0.0.0.0:50259/ (Press CTRL+C to quit)
localstack_main | 2020-07-13 19:37:13,787:API:  * Running on http://0.0.0.0:50259/ (Press CTRL+C to quit)
localstack_main | 2020-07-13 19:37:13,813:API:  * Running on http://0.0.0.0:47809/ (Press CTRL+C to quit)
localstack_main | 2020-07-13 19:37:13,813:API:  * Running on http://0.0.0.0:47809/ (Press CTRL+C to quit)
localstack_main | 2020-07-13 19:37:13,813:API:  * Running on http://0.0.0.0:47809/ (Press CTRL+C to quit)
localstack_main | 2020-07-13 19:37:13,829:API:  * Running on http://0.0.0.0:4592/ (Press CTRL+C to quit)
localstack_main | 2020-07-13 19:37:13,829:API:  * Running on http://0.0.0.0:4592/ (Press CTRL+C to quit)
localstack_main | 2020-07-13 19:37:13,829:API:  * Running on http://0.0.0.0:4592/ (Press CTRL+C to quit)
localstack_main | Running on 0.0.0.0:4586 over http (CTRL + C to quit)
localstack_main | Running on 0.0.0.0:4572 over http (CTRL + C to quit)
localstack_main | Initializing DynamoDB Local with the following configuration:
localstack_main | Port: 48725
localstack_main | InMemory:     true
localstack_main | DbPath:       null
localstack_main | SharedDb:     true
localstack_main | shouldDelayTransientStatuses: false
localstack_main | CorsParams:   *
localstack_main | 
localstack_main | Waiting for all LocalStack services to be ready
localstack_main | Ready.
whummer commented 4 years ago

Hi @ngouass , thanks for the quick follow-up! This should be fixed now in the latest version - can you please pull the latest image one more time? Thanks for your help.

ngouass commented 4 years ago

Thanks for the quick fix @whummer, it works WELL now !