aws / aws-sam-cli

CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM
https://aws.amazon.com/serverless/sam/
Apache License 2.0
6.51k stars 1.17k forks source link

sam build -u vs sam Build -u -b directory structure #1284

Closed viksrivat closed 5 years ago

viksrivat commented 5 years ago

Description

Running sam build -u -b folder creates a nested directory structure that is not shown when running sam build. This will not block deployment or anything, but could be a cause for potential bugs when SAM-CLI updates sam build.

Steps to reproduce

The example below is a slightly modified version of the sam init --runtime python3.6 hello world app that use 3 functions instead of 1 in order to display the bug. template.yaml:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
  sam-app

  Sample SAM Template for sam-app

# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
  Function:
    Timeout: 3

Resources:
  HelloWorldFunction:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      CodeUri: '.'
      Handler: app.lambda_handler
      Runtime: python3.6
      Events:
        HelloWorld:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            Path: /hello
            Method: get
  AnotherFunction2:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      CodeUri: '.'
      Handler: app.handler
      Runtime: python3.6
      Events:
        HelloWorld:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            Path: /basic
            Method: get
  AnotherFunction3:
    Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
    Properties:
      CodeUri: '.'
      Handler: basic_nested.handler
      Runtime: python3.6
      Events:
        HelloWorld:
          Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
          Properties:
            Path: /nested
            Method: get
Outputs:
  # ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
  # Find out more about other implicit resources you can reference within SAM
  # https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
  HelloWorldApi:
    Description: "API Gateway endpoint URL for Prod stage for Hello World function"
    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"
  HelloWorldFunction:
    Description: "Hello World Lambda Function ARN"
    Value: !GetAtt HelloWorldFunction.Arn
  HelloWorldFunctionIamRole:
    Description: "Implicit IAM Role created for Hello World function"
    Value: !GetAtt HelloWorldFunctionRole.Arn

requirements.txt:

app.py:

import json

def lambda_handler(event, context):
    return {
        "statusCode": 200,
        "body": json.dumps({
            "message": "hello world",
        }),
    }

def handler2(event, context):
    return {"statusCode": 200, "body": json.dumps({"Another": "Function2"})}

def handler3(event, context):
    return {"statusCode": 200, "body": json.dumps({"Another": "Function3"})}

Observed result

The directory structure

.
├── AnotherFunction2
│   ├── .gitignore
│   ├── .sam-aws
│   │   └── HelloWorldFunction
│   │       ├── .gitignore
│   │       ├── .sam-aws
│   │       ├── README.md
│   │       ├── app.py
│   │       ├── requirements.txt
│   │       ├── template.yaml
│   │       └── tests
│   │           └── unit
│   │               ├── __init__.py
│   │               └── test_handler.py
│   ├── README.md
│   ├── app.py
│   ├── requirements.txt
│   ├── template.yaml
│   └── tests
│       └── unit
│           ├── __init__.py
│           └── test_handler.py
├── AnotherFunction3
│   ├── .gitignore
│   ├── .sam-aws
│   │   ├── AnotherFunction2
│   │   │   ├── .gitignore
│   │   │   ├── .sam-aws
│   │   │   │   └── HelloWorldFunction
│   │   │   │       ├── .gitignore
│   │   │   │       ├── .sam-aws
│   │   │   │       ├── README.md
│   │   │   │       ├── app.py
│   │   │   │       ├── requirements.txt
│   │   │   │       ├── template.yaml
│   │   │   │       └── tests
│   │   │   │           └── unit
│   │   │   │               ├── __init__.py
│   │   │   │               └── test_handler.py
│   │   │   ├── README.md
│   │   │   ├── app.py
│   │   │   ├── requirements.txt
│   │   │   ├── template.yaml
│   │   │   └── tests
│   │   │       └── unit
│   │   │           ├── __init__.py
│   │   │           └── test_handler.py
│   │   └── HelloWorldFunction
│   │       ├── .gitignore
│   │       ├── .sam-aws
│   │       ├── README.md
│   │       ├── app.py
│   │       ├── requirements.txt
│   │       ├── template.yaml
│   │       └── tests
│   │           └── unit
│   │               ├── __init__.py
│   │               └── test_handler.py
│   ├── README.md
│   ├── app.py
│   ├── requirements.txt
│   ├── template.yaml
│   └── tests
│       └── unit
│           ├── __init__.py
│           └── test_handler.py
├── HelloWorldFunction
│   ├── .gitignore
│   ├── .sam-aws
│   ├── README.md
│   ├── app.py
│   ├── requirements.txt
│   ├── template.yaml
│   └── tests
│       └── unit
│           ├── __init__.py
│           └── test_handler.py
├── template.yaml
└── test.txt

Please provide command output with --debug flag set. Debug Output with sam build --debug:

2019-07-22 15:45:57 Using SAM Template at /Users/viksriva/Documents/sandbox/tmp/sam-app/template.yaml
2019-07-22 15:45:57 Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
2019-07-22 15:45:57 Changing event name from before-call.apigateway to before-call.api-gateway
2019-07-22 15:45:57 Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
2019-07-22 15:45:57 Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
2019-07-22 15:45:57 Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2019-07-22 15:45:57 Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
2019-07-22 15:45:57 Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
2019-07-22 15:45:57 Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
2019-07-22 15:45:57 Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
2019-07-22 15:45:57 Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
2019-07-22 15:45:57 Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
2019-07-22 15:45:57 Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-plane
2019-07-22 15:45:57 Changing event name from before-call.apigateway to before-call.api-gateway
2019-07-22 15:45:57 Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.Predict
2019-07-22 15:45:57 Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfiguration
2019-07-22 15:45:57 Changing event name from before-parameter-build.route53 to before-parameter-build.route-53
2019-07-22 15:45:57 Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.Search
2019-07-22 15:45:57 Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-section
2019-07-22 15:45:57 Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTask
2019-07-22 15:45:57 Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-section
2019-07-22 15:45:57 Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.Search
2019-07-22 15:45:57 Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-section
2019-07-22 15:45:57 'build' command is called
2019-07-22 15:45:57 Starting Build inside a container
2019-07-22 15:45:57 No Parameters detected in the template
2019-07-22 15:45:57 4 resources found in the template
2019-07-22 15:45:57 Found Serverless function with name='HelloWorldFunction' and CodeUri='.'
2019-07-22 15:45:57 Found Serverless function with name='AnotherFunction2' and CodeUri='.'
2019-07-22 15:45:57 Found Serverless function with name='AnotherFunction3' and CodeUri='.'
2019-07-22 15:45:57 Trying paths: ['/Users/viksriva/.docker/config.json', '/Users/viksriva/.dockercfg']
2019-07-22 15:45:57 Found file at path: /Users/viksriva/.docker/config.json
2019-07-22 15:45:57 Found 'auths' section
2019-07-22 15:45:57 Auth data for https://index.docker.io/v1/ is absent. Client might be using a credentials store instead.
2019-07-22 15:45:57 Building resource 'HelloWorldFunction'
2019-07-22 15:45:57 http://localhost:None "GET /v1.35/_ping HTTP/1.1" 200 2
2019-07-22 15:45:57 Trying paths: ['/Users/viksriva/.docker/config.json', '/Users/viksriva/.dockercfg']
2019-07-22 15:45:57 Found file at path: /Users/viksriva/.docker/config.json
2019-07-22 15:45:57 Found 'auths' section
2019-07-22 15:45:57 Auth data for https://index.docker.io/v1/ is absent. Client might be using a credentials store instead.
2019-07-22 15:45:57 http://localhost:None "GET /v1.35/images/lambci/lambda:build-python3.6/json HTTP/1.1" 200 None
2019-07-22 15:45:57 Looking for auth config
2019-07-22 15:45:57 Looking for auth entry for 'docker.io'
2019-07-22 15:45:57 Found 'https://index.docker.io/v1/'
2019-07-22 15:45:57 No auth config found
2019-07-22 15:45:58 http://localhost:None "POST /v1.35/images/create?tag=build-python3.6&fromImage=lambci%2Flambda HTTP/1.1" 200 None

Fetching lambci/lambda:build-python3.6 Docker container image......
2019-07-22 15:45:58 Mounting /Users/viksriva/Documents/sandbox/tmp/sam-app as /tmp/samcli/source:ro,delegated inside runtime container
2019-07-22 15:45:58 http://localhost:None "POST /v1.35/containers/create HTTP/1.1" 201 90
2019-07-22 15:45:58 http://localhost:None "GET /v1.35/containers/f5c06873950893e6b506ae19ec4dbd4d9a8faf124b632eaa4b99d034e7a7ba62/json HTTP/1.1" 200 None
2019-07-22 15:45:58 http://localhost:None "GET /v1.35/containers/f5c06873950893e6b506ae19ec4dbd4d9a8faf124b632eaa4b99d034e7a7ba62/json HTTP/1.1" 200 None
2019-07-22 15:45:59 http://localhost:None "POST /v1.35/containers/f5c06873950893e6b506ae19ec4dbd4d9a8faf124b632eaa4b99d034e7a7ba62/start HTTP/1.1" 204 0
2019-07-22 15:45:59 http://localhost:None "GET /v1.35/containers/f5c06873950893e6b506ae19ec4dbd4d9a8faf124b632eaa4b99d034e7a7ba62/json HTTP/1.1" 200 None
2019-07-22 15:45:59 http://localhost:None "POST /containers/f5c06873950893e6b506ae19ec4dbd4d9a8faf124b632eaa4b99d034e7a7ba62/attach?stdout=1&stderr=1&logs=1&stream=1&stdin=0 HTTP/1.1" 101 0
Using the request object from command line argument
Loading workflow module 'aws_lambda_builders.workflows'
Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'
Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'
Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'
Registering workflow 'GoDepBuilder' with capability 'Capability(language='go', dependency_manager='dep', application_framework=None)'
Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'
Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)'
Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
Found workflow 'PythonPipBuilder' to support capabilities 'Capability(language='python', dependency_manager='pip', application_framework=None)'
Running workflow 'PythonPipBuilder'
Running PythonPipBuilder:ResolveDependencies
PythonPipBuilder:ResolveDependencies succeeded
Running PythonPipBuilder:CopySource
PythonPipBuilder:CopySource succeeded
2019-07-22 15:45:59 Build inside container returned response {"jsonrpc": "2.0", "id": 1, "result": {"artifacts_dir": "/tmp/samcli/artifacts"}}
2019-07-22 15:45:59 Build inside container was successful. Copying artifacts from container to host
2019-07-22 15:45:59 http://localhost:None "GET /v1.35/containers/f5c06873950893e6b506ae19ec4dbd4d9a8faf124b632eaa4b99d034e7a7ba62/json HTTP/1.1" 200 None
2019-07-22 15:45:59 Copying from container: /tmp/samcli/artifacts/. -> /Users/viksriva/Documents/sandbox/tmp/sam-app/.sam-aws/HelloWorldFunction
2019-07-22 15:45:59 http://localhost:None "GET /v1.35/containers/f5c06873950893e6b506ae19ec4dbd4d9a8faf124b632eaa4b99d034e7a7ba62/archive?path=%2Ftmp%2Fsamcli%2Fartifacts%2F. HTTP/1.1" 200 None
2019-07-22 15:45:59 http://localhost:None "GET /v1.35/containers/f5c06873950893e6b506ae19ec4dbd4d9a8faf124b632eaa4b99d034e7a7ba62/json HTTP/1.1" 200 None
2019-07-22 15:45:59 http://localhost:None "DELETE /v1.35/containers/f5c06873950893e6b506ae19ec4dbd4d9a8faf124b632eaa4b99d034e7a7ba62?v=False&link=False&force=True HTTP/1.1" 204 0
2019-07-22 15:45:59 Build inside container succeeded
2019-07-22 15:45:59 Building resource 'AnotherFunction2'
2019-07-22 15:45:59 http://localhost:None "GET /v1.35/_ping HTTP/1.1" 200 2
2019-07-22 15:45:59 Trying paths: ['/Users/viksriva/.docker/config.json', '/Users/viksriva/.dockercfg']
2019-07-22 15:45:59 Found file at path: /Users/viksriva/.docker/config.json
2019-07-22 15:45:59 Found 'auths' section
2019-07-22 15:45:59 Auth data for https://index.docker.io/v1/ is absent. Client might be using a credentials store instead.
2019-07-22 15:46:00 http://localhost:None "GET /v1.35/images/lambci/lambda:build-python3.6/json HTTP/1.1" 200 None
2019-07-22 15:46:00 Looking for auth config
2019-07-22 15:46:00 Looking for auth entry for 'docker.io'
2019-07-22 15:46:00 Found 'https://index.docker.io/v1/'
2019-07-22 15:46:00 No auth config found
2019-07-22 15:46:01 http://localhost:None "POST /v1.35/images/create?tag=build-python3.6&fromImage=lambci%2Flambda HTTP/1.1" 200 None

Fetching lambci/lambda:build-python3.6 Docker container image......
2019-07-22 15:46:01 Mounting /Users/viksriva/Documents/sandbox/tmp/sam-app as /tmp/samcli/source:ro,delegated inside runtime container
2019-07-22 15:46:01 http://localhost:None "POST /v1.35/containers/create HTTP/1.1" 201 90
2019-07-22 15:46:01 http://localhost:None "GET /v1.35/containers/5a70ad8a578bfcc62693bb4b34d31f8efd922ba88971518f734e9ea8528017f9/json HTTP/1.1" 200 None
2019-07-22 15:46:01 http://localhost:None "GET /v1.35/containers/5a70ad8a578bfcc62693bb4b34d31f8efd922ba88971518f734e9ea8528017f9/json HTTP/1.1" 200 None
2019-07-22 15:46:02 http://localhost:None "POST /v1.35/containers/5a70ad8a578bfcc62693bb4b34d31f8efd922ba88971518f734e9ea8528017f9/start HTTP/1.1" 204 0
2019-07-22 15:46:02 http://localhost:None "GET /v1.35/containers/5a70ad8a578bfcc62693bb4b34d31f8efd922ba88971518f734e9ea8528017f9/json HTTP/1.1" 200 None
2019-07-22 15:46:02 http://localhost:None "POST /containers/5a70ad8a578bfcc62693bb4b34d31f8efd922ba88971518f734e9ea8528017f9/attach?stdout=1&stderr=1&logs=1&stream=1&stdin=0 HTTP/1.1" 101 0
Using the request object from command line argument
Loading workflow module 'aws_lambda_builders.workflows'
Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'
Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'
Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'
Registering workflow 'GoDepBuilder' with capability 'Capability(language='go', dependency_manager='dep', application_framework=None)'
Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'
Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)'
Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
Found workflow 'PythonPipBuilder' to support capabilities 'Capability(language='python', dependency_manager='pip', application_framework=None)'
Running workflow 'PythonPipBuilder'
Running PythonPipBuilder:ResolveDependencies
PythonPipBuilder:ResolveDependencies succeeded
Running PythonPipBuilder:CopySource
PythonPipBuilder:CopySource succeeded
2019-07-22 15:46:02 Build inside container returned response {"jsonrpc": "2.0", "id": 1, "result": {"artifacts_dir": "/tmp/samcli/artifacts"}}
2019-07-22 15:46:02 Build inside container was successful. Copying artifacts from container to host
2019-07-22 15:46:02 http://localhost:None "GET /v1.35/containers/5a70ad8a578bfcc62693bb4b34d31f8efd922ba88971518f734e9ea8528017f9/json HTTP/1.1" 200 None
2019-07-22 15:46:02 Copying from container: /tmp/samcli/artifacts/. -> /Users/viksriva/Documents/sandbox/tmp/sam-app/.sam-aws/AnotherFunction2
2019-07-22 15:46:02 http://localhost:None "GET /v1.35/containers/5a70ad8a578bfcc62693bb4b34d31f8efd922ba88971518f734e9ea8528017f9/archive?path=%2Ftmp%2Fsamcli%2Fartifacts%2F. HTTP/1.1" 200 None
2019-07-22 15:46:03 http://localhost:None "GET /v1.35/containers/5a70ad8a578bfcc62693bb4b34d31f8efd922ba88971518f734e9ea8528017f9/json HTTP/1.1" 200 None
2019-07-22 15:46:03 http://localhost:None "DELETE /v1.35/containers/5a70ad8a578bfcc62693bb4b34d31f8efd922ba88971518f734e9ea8528017f9?v=False&link=False&force=True HTTP/1.1" 204 0
2019-07-22 15:46:03 Build inside container succeeded
2019-07-22 15:46:03 Building resource 'AnotherFunction3'
2019-07-22 15:46:03 http://localhost:None "GET /v1.35/_ping HTTP/1.1" 200 2
2019-07-22 15:46:03 Trying paths: ['/Users/viksriva/.docker/config.json', '/Users/viksriva/.dockercfg']
2019-07-22 15:46:03 Found file at path: /Users/viksriva/.docker/config.json
2019-07-22 15:46:03 Found 'auths' section
2019-07-22 15:46:03 Auth data for https://index.docker.io/v1/ is absent. Client might be using a credentials store instead.
2019-07-22 15:46:03 http://localhost:None "GET /v1.35/images/lambci/lambda:build-python3.6/json HTTP/1.1" 200 None
2019-07-22 15:46:03 Looking for auth config
2019-07-22 15:46:03 Looking for auth entry for 'docker.io'
2019-07-22 15:46:03 Found 'https://index.docker.io/v1/'
2019-07-22 15:46:03 No auth config found
2019-07-22 15:46:04 http://localhost:None "POST /v1.35/images/create?tag=build-python3.6&fromImage=lambci%2Flambda HTTP/1.1" 200 None

Fetching lambci/lambda:build-python3.6 Docker container image......
2019-07-22 15:46:04 Mounting /Users/viksriva/Documents/sandbox/tmp/sam-app as /tmp/samcli/source:ro,delegated inside runtime container
2019-07-22 15:46:04 http://localhost:None "POST /v1.35/containers/create HTTP/1.1" 201 90
2019-07-22 15:46:04 http://localhost:None "GET /v1.35/containers/fa6c69e92033e02103e91e18055f25498c6f6866bb2bcd50016c8d9d34c79a08/json HTTP/1.1" 200 None
2019-07-22 15:46:04 http://localhost:None "GET /v1.35/containers/fa6c69e92033e02103e91e18055f25498c6f6866bb2bcd50016c8d9d34c79a08/json HTTP/1.1" 200 None
2019-07-22 15:46:05 http://localhost:None "POST /v1.35/containers/fa6c69e92033e02103e91e18055f25498c6f6866bb2bcd50016c8d9d34c79a08/start HTTP/1.1" 204 0
2019-07-22 15:46:05 http://localhost:None "GET /v1.35/containers/fa6c69e92033e02103e91e18055f25498c6f6866bb2bcd50016c8d9d34c79a08/json HTTP/1.1" 200 None
2019-07-22 15:46:05 http://localhost:None "POST /containers/fa6c69e92033e02103e91e18055f25498c6f6866bb2bcd50016c8d9d34c79a08/attach?stdout=1&stderr=1&logs=1&stream=1&stdin=0 HTTP/1.1" 101 0
Using the request object from command line argument
Loading workflow module 'aws_lambda_builders.workflows'
Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'
Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'
Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'
Registering workflow 'GoDepBuilder' with capability 'Capability(language='go', dependency_manager='dep', application_framework=None)'
Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'
Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)'
Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
Found workflow 'PythonPipBuilder' to support capabilities 'Capability(language='python', dependency_manager='pip', application_framework=None)'
Running workflow 'PythonPipBuilder'
Running PythonPipBuilder:ResolveDependencies
PythonPipBuilder:ResolveDependencies succeeded
Running PythonPipBuilder:CopySource
PythonPipBuilder:CopySource succeeded
2019-07-22 15:46:05 Build inside container returned response {"jsonrpc": "2.0", "id": 1, "result": {"artifacts_dir": "/tmp/samcli/artifacts"}}
2019-07-22 15:46:05 Build inside container was successful. Copying artifacts from container to host
2019-07-22 15:46:06 http://localhost:None "GET /v1.35/containers/fa6c69e92033e02103e91e18055f25498c6f6866bb2bcd50016c8d9d34c79a08/json HTTP/1.1" 200 None
2019-07-22 15:46:06 Copying from container: /tmp/samcli/artifacts/. -> /Users/viksriva/Documents/sandbox/tmp/sam-app/.sam-aws/AnotherFunction3
2019-07-22 15:46:06 http://localhost:None "GET /v1.35/containers/fa6c69e92033e02103e91e18055f25498c6f6866bb2bcd50016c8d9d34c79a08/archive?path=%2Ftmp%2Fsamcli%2Fartifacts%2F. HTTP/1.1" 200 None
2019-07-22 15:46:06 http://localhost:None "GET /v1.35/containers/fa6c69e92033e02103e91e18055f25498c6f6866bb2bcd50016c8d9d34c79a08/json HTTP/1.1" 200 None
2019-07-22 15:46:06 http://localhost:None "DELETE /v1.35/containers/fa6c69e92033e02103e91e18055f25498c6f6866bb2bcd50016c8d9d34c79a08?v=False&link=False&force=True HTTP/1.1" 204 0
2019-07-22 15:46:06 Build inside container succeeded

Expected result

Describe what you expected. The directory structure should be like the output from sam build:

.
├── AnotherFunction2
│   ├── README.md
│   ├── app.py
│   ├── requirements.txt
│   ├── template.yaml
│   └── tests
│       └── unit
│           ├── __init__.py
│           └── test_handler.py
├── AnotherFunction3
│   ├── README.md
│   ├── app.py
│   ├── requirements.txt
│   ├── template.yaml
│   └── tests
│       └── unit
│           ├── __init__.py
│           └── test_handler.py
├── HelloWorldFunction
│   ├── README.md
│   ├── app.py
│   ├── requirements.txt
│   ├── template.yaml
│   └── tests
│       └── unit
│           ├── __init__.py
│           └── test_handler.py
└── template.yaml

sam build -b folder -u should create the same structure as sam build -u

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Mac
  2. sam --version: SAM CLI, version 0.18.0
viksrivat commented 5 years ago

Fixed by moving python code to a new folder instead of using "."