docs icon indicating copy to clipboard operation
docs copied to clipboard

Update AWS SAM - VS Code configuration

Open MarcelStranak opened this issue 2 years ago • 0 comments

Add a point about the needed configuration for AWS SAM in VS Code, launch.json.

It is important to mention the dockerNetwork property, which initiates the LocalStack container to execute the SAM local invoke command in the same network as the LocalStack container. See https://docs.aws.amazon.com/cloud9/latest/user-guide/sam-debug-config-ref.html.

Example:

{
            "type": "aws-sam",
            "request": "direct-invoke",
            "name": "Job dispatcher lambda",
            "invokeTarget": {
                "target": "code",
                "projectRoot": "${workspaceFolder}",
                "lambdaHandler": "lambda/lambda.handler"
            },
            "lambda": {
                "runtime": "python3.8",
                "payload": {},
                "environmentVariables": {
                    "ENDPOINT_URL": "http://localstack:4566/",
                    "S3_ENDPOINT_URL": "http://s3.localhost.localstack.cloud:4566/",
                    "AWS_ACCESS_KEY_ID": "test",
                    "AWS_SECRET_ACCESS_KEY": "test",
                    "AWS_SESSION_TOKEN": "test",
                    "AWS_REGION": "us-east-1",
                    "MAIN_DOCKER_NETWORK": "localstack-network"
                }
            },
            "sam": {
                "dockerNetwork": "localstack-network"
            }
        }

MarcelStranak avatar Jun 09 '23 12:06 MarcelStranak