amazon-archives / aws-amplify-serverless-plugin

Plugin for the Serverless Framework to output AWS Amplify configuration files.
Apache License 2.0
124 stars 30 forks source link

Error when stack name is generated #40

Closed adrianhall closed 5 years ago

adrianhall commented 5 years ago

Error:

ERROR: amplify-plugin: Cannot load resources: 1 validation error detected: Value 'RestaurantReviews-${opt:stage, "dev"}' at 'stackNameOrId' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z][-a-zA-Z0-9]*|arn:[-a-zA-Z0-9:/._+]*
$ sls invoke -f postdeployment -v
{
    "errorMessage": "b'{\"acknowledged\":true,\"shards_acknowledged\":true,\"index\":\"devrestaurantreviews\"}' is not JSON serializable",
    "errorType": "TypeError",
    "stackTrace": [
        [
            "/var/lang/lib/python3.6/json/__init__.py",
            238,
            "dumps",
            "**kw).encode(obj)"
        ],
        [
            "/var/lang/lib/python3.6/json/encoder.py",
            199,
            "encode",
            "chunks = self.iterencode(o, _one_shot=True)"
        ],
        [
            "/var/lang/lib/python3.6/json/encoder.py",
            257,
            "iterencode",
            "return _iterencode(o, 0)"
        ],
        [
            "/var/runtime/awslambda/bootstrap.py",
            110,
            "decimal_serializer",
            "raise TypeError(repr(o) + \" is not JSON serializable\")"
        ]
    ]
}
adrianhall commented 5 years ago

The problem here is where the stack name is being read. I was reading the stack name previously when the plugin was initialized. However, what I needed to do was read it when the hook was triggered. Reading the stack name during initialization results in a read that includes the variable instead of the expansion of the variable.

adrianhall commented 5 years ago

Fixed in v1.2.1