title: Deploying Lambda Function with CDK Failing Due to Missing Parameters
body: <pre><code>new Function(this, "TestFunction", {
      handler: "TestFunction.handler",
      code: Code.asset(path.join(__dirname, "lambdas/")),
      runtime: Runtime.NodeJS810
  });
  </code></pre>
  
  <p>When I try to deploy this to CodeDeploy, I get: </p>
  
  <pre><code>Parameters: [TestFunctionCodeS3Bucket, TestFunctionCodeS3VersionKey] must have values (Service: AmazonCloudFormation; Status Code: 400; Error Code: ValidationError;
  </code></pre>
  
  <p>When I check the CloudFormation generated, I can see the parameters:</p>
  
  <pre><code>TestFunctionCodeS3Bucket:
      Type: String
      Description: S3 bucket for asset "AppStack/TestFunction/Code"
  TestFunctionCodeS3VersionKey:
      Type: String
      Description: S3 key for asset version "AppStack/TestFunction/Code"
  </code></pre>
  
  <p>My understanding is that <code>Code.asset</code> should bootstrap this process on its own. Is there a step I'm missing here?</p>
  
  <p>Looking at the docs (<a href="https://docs.aws.amazon.com/cdk/latest/guide/serverless_example.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/cdk/latest/guide/serverless_example.html</a>), it states that you're suppose to create an <code>Amazon S3 bucket that contains the Lambda function code.</code> However, nowhere in the example do I see that being done explicitly. So I just assumed it was done implicitly.</p>
  
  <p>Generated CFN:</p>
  
  <pre><code>Parameters:
    TestFunctionCodeS3BucketE8C956AE:
      Type: String
      Description: S3 bucket for asset "AppStack/TestFunction/Code"
    TestFunctionCodeS3VersionKey6B3F3155:
      Type: String
      Description: S3 key for asset version "AppStack/TestFunction/Code"
  Resources:
    TestFunctionServiceRole6ABD93C7:
      Type: AWS::IAM::Role
      Properties:
        AssumeRolePolicyDocument:
          Statement:
            - Action: sts:AssumeRole
              Effect: Allow
              Principal:
                Service: lambda.amazonaws.com
          Version: "2012-10-17"
        ManagedPolicyArns:
          - Fn::Join:
              - ""
              - - "arn:"
                - Ref: AWS::Partition
                - :iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
      Metadata:
        aws:cdk:path: AppStack/TestFunction/ServiceRole/Resource
    TestFunction22AD90FC:
      Type: AWS::Lambda::Function
      Properties:
        Code:
          S3Bucket:
            Ref: TestFunctionCodeS3BucketE8C956AE
          S3Key:
            Fn::Join:
              - ""
              - - Fn::Select:
                    - 0
                    - Fn::Split:
                        - "||"
                        - Ref: TestFunctionCodeS3VersionKey6B3F3155
                - Fn::Select:
                    - 1
                    - Fn::Split:
                        - "||"
                        - Ref: TestFunctionCodeS3VersionKey6B3F3155
        Handler: TestFunction.handler
        Role:
          Fn::GetAtt:
            - TestFunctionServiceRole6ABD93C7
            - Arn
        Runtime: nodejs8.10
      DependsOn:
        - TestFunctionServiceRole6ABD93C7
      Metadata:
        aws:cdk:path: AppStack/TestFunction/Resource
        aws:asset:path: /Volumes/Unix/AMCC/src/AMCConsole/packages/infrastructure/lib/lambdas/mars
        aws:asset:property: Code
    CDKMetadata:
      Type: AWS::CDK::Metadata
      Properties:
        Modules: aws-cdk=0.22.0,@aws-cdk/assets=0.22.0,@aws-cdk/assets-docker=0.22.0,@aws-cdk/aws-apigateway=0.22.0,@aws-cdk/aws-cloudformation=0.22.0,@aws-cdk/aws-cloudfront=0.22.0,@aws-cdk/aws-cloudwatch=0.22.0,@aws-cdk/aws-codebuild=0.22.0,@aws-cdk/aws-codecommit=0.22.0,@aws-cdk/aws-codepipeline=0.22.0,@aws-cdk/aws-codepipeline-api=0.22.0,@aws-cdk/aws-cognito=0.22.0,@aws-cdk/aws-ec2=0.22.0,@aws-cdk/aws-ecr=0.22.0,@aws-cdk/aws-events=0.22.0,@aws-cdk/aws-iam=0.22.0,@aws-cdk/aws-kms=0.22.0,@aws-cdk/aws-lambda=0.22.0,@aws-cdk/aws-route53=0.22.0,@aws-cdk/aws-s3=0.22.0,@aws-cdk/aws-s3-notifications=0.22.0,@aws-cdk/aws-serverless=0.22.0,@aws-cdk/aws-sns=0.22.0,@aws-cdk/aws-sqs=0.22.0,@aws-cdk/cdk=0.22.0,@aws-cdk/cx-api=0.22.0,jsii-runtime=node.js/v11.12.0
  </code></pre>