Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Generate sam build schema #5505

Merged
merged 8 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samcli/commands/build/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
multiple=True, # Can pass in multiple env vars
required=False,
help="Environment variables to be passed into build containers"
"Resource format (FuncName.VarName=Value) or Global format (VarName=Value)."
"\nResource format (FuncName.VarName=Value) or Global format (VarName=Value)."
"\n\n Example: --container-env-var Func1.VAR1=value1 --container-env-var VAR2=value2",
cls=ContainerOptions,
)
Expand Down
125 changes: 122 additions & 3 deletions schema/samcli.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,128 @@
"properties": {
"parameters": {
"title": "Parameters for the build command",
"description": "Available parameters for the build command:\n",
"description": "Available parameters for the build command:\n* hook_name:\nHook package id to extend AWS SAM CLI commands functionality. \n\nExample: `terraform` to extend AWS SAM CLI commands functionality to support terraform applications. \n\nAvailable Hook Names: ['terraform']\n* skip_prepare_infra:\nSkip preparation stage when there are no infrastructure changes. Only used in conjunction with --hook-name.\n* use_container:\nBuild functions within an AWS Lambda-like container.\n* container_env_var:\nEnvironment variables to be passed into build containers\nResource format (FuncName.VarName=Value) or Global format (VarName=Value).\n\n Example: --container-env-var Func1.VAR1=value1 --container-env-var VAR2=value2\n* container_env_var_file:\nEnvironment variables json file (e.g., env_vars.json) to be passed to build containers.\n* build_image:\nContainer image URIs for building functions/layers. You can specify for all functions/layers with just the image URI (--build-image public.ecr.aws/sam/build-nodejs18.x:latest). You can specify for each individual function with (--build-image FunctionLogicalID=public.ecr.aws/sam/build-nodejs18.x:latest). A combination of the two can be used. If a function does not have build image specified or an image URI for all functions, the default SAM CLI build images will be used.\n* exclude:\nName of the resource(s) to exclude from AWS SAM CLI build.\n* parallel:\nEnable parallel builds for AWS SAM template's functions and layers.\n* mount_with:\nSpecify mount mode for building functions/layers inside container. If it is mounted with write permissions, some files in source code directory may be changed/added by the build process. By default the source code directory is read only.\n* build_dir:\nDirectory to store build artifacts.Note: This directory will be first removed before starting a build.\n* cache_dir:\nDirectory to store cached artifacts. The default cache directory is .aws-sam/cache\n* base_dir:\nResolve relative paths to function's source code with respect to this directory. Use this if SAM template and source code are not in same enclosing folder. By default, relative paths are resolved with respect to the SAM template's location.\n* manifest:\nPath to a custom dependency manifest. Example: custom-package.json\n* cached:\nEnable cached builds.Reuse build artifacts that have not changed from previous builds. \n\nAWS SAM CLI evaluates if files in your project directory have changed. \n\nNote: AWS SAM CLI does not evaluate changes made to third party modules that the project depends on.Example: Python function includes a requirements.txt file with the following entry requests=1.x and the latest request module version changes from 1.1 to 1.2, AWS SAM CLI will not pull the latest version until a non-cached build is run.\n* template_file:\nAWS SAM template file.\n* parameter_overrides:\nString that contains AWS CloudFormation parameter overrides encoded as key=value pairs.\n* skip_pull_image:\nSkip pulling down the latest Docker image for Lambda runtime.\n* docker_network:\nName or ID of an existing docker network for AWS Lambda docker containers to connect to, along with the default bridge network. If not specified, the Lambda containers will only connect to the default bridge docker network.\n* beta_features:\nEnable/Disable beta features.\n* debug:\nTurn on debug logging to print debug message generated by AWS SAM CLI and display timestamps.\n* profile:\nSelect a specific profile from your credential file to get AWS credentials.\n* region:\nSet the AWS Region of the service. (e.g. us-east-1)",
"type": "object",
"properties": {}
"properties": {
"hook_name": {
"title": "hook_name",
"type": "string",
"description": "Hook package id to extend AWS SAM CLI commands functionality. \n\nExample: `terraform` to extend AWS SAM CLI commands functionality to support terraform applications. \n\nAvailable Hook Names: ['terraform']"
},
"skip_prepare_infra": {
"title": "skip_prepare_infra",
"type": "boolean",
"description": "Skip preparation stage when there are no infrastructure changes. Only used in conjunction with --hook-name."
},
"use_container": {
"title": "use_container",
"type": "boolean",
"description": "Build functions within an AWS Lambda-like container."
},
"container_env_var": {
"title": "container_env_var",
"type": "string",
"description": "Environment variables to be passed into build containers\nResource format (FuncName.VarName=Value) or Global format (VarName=Value).\n\n Example: --container-env-var Func1.VAR1=value1 --container-env-var VAR2=value2"
},
"container_env_var_file": {
"title": "container_env_var_file",
"type": "string",
"description": "Environment variables json file (e.g., env_vars.json) to be passed to build containers."
},
"build_image": {
"title": "build_image",
"type": "string",
"description": "Container image URIs for building functions/layers. You can specify for all functions/layers with just the image URI (--build-image public.ecr.aws/sam/build-nodejs18.x:latest). You can specify for each individual function with (--build-image FunctionLogicalID=public.ecr.aws/sam/build-nodejs18.x:latest). A combination of the two can be used. If a function does not have build image specified or an image URI for all functions, the default SAM CLI build images will be used."
},
"exclude": {
"title": "exclude",
"type": "string",
"description": "Name of the resource(s) to exclude from AWS SAM CLI build."
},
"parallel": {
"title": "parallel",
"type": "boolean",
"description": "Enable parallel builds for AWS SAM template's functions and layers."
},
"mount_with": {
"title": "mount_with",
"type": "string",
"description": "Specify mount mode for building functions/layers inside container. If it is mounted with write permissions, some files in source code directory may be changed/added by the build process. By default the source code directory is read only.",
"default": "READ",
"enum": [
"READ",
"WRITE"
]
},
"build_dir": {
"title": "build_dir",
"type": "string",
"description": "Directory to store build artifacts.Note: This directory will be first removed before starting a build.",
"default": ".aws-sam/build"
},
"cache_dir": {
"title": "cache_dir",
"type": "string",
"description": "Directory to store cached artifacts. The default cache directory is .aws-sam/cache",
"default": ".aws-sam/cache"
},
"base_dir": {
"title": "base_dir",
"type": "string",
"description": "Resolve relative paths to function's source code with respect to this directory. Use this if SAM template and source code are not in same enclosing folder. By default, relative paths are resolved with respect to the SAM template's location."
},
"manifest": {
"title": "manifest",
"type": "string",
"description": "Path to a custom dependency manifest. Example: custom-package.json"
},
"cached": {
"title": "cached",
"type": "boolean",
"description": "Enable cached builds.Reuse build artifacts that have not changed from previous builds. \n\nAWS SAM CLI evaluates if files in your project directory have changed. \n\nNote: AWS SAM CLI does not evaluate changes made to third party modules that the project depends on.Example: Python function includes a requirements.txt file with the following entry requests=1.x and the latest request module version changes from 1.1 to 1.2, AWS SAM CLI will not pull the latest version until a non-cached build is run."
},
"template_file": {
"title": "template_file",
"type": "string",
"description": "AWS SAM template file.",
"default": "template.[yaml|yml|json]"
},
"parameter_overrides": {
"title": "parameter_overrides",
"type": "string",
"description": "String that contains AWS CloudFormation parameter overrides encoded as key=value pairs."
},
"skip_pull_image": {
"title": "skip_pull_image",
"type": "boolean",
"description": "Skip pulling down the latest Docker image for Lambda runtime."
},
"docker_network": {
"title": "docker_network",
"type": "string",
"description": "Name or ID of an existing docker network for AWS Lambda docker containers to connect to, along with the default bridge network. If not specified, the Lambda containers will only connect to the default bridge docker network."
},
"beta_features": {
"title": "beta_features",
"type": "boolean",
"description": "Enable/Disable beta features."
},
"debug": {
"title": "debug",
"type": "boolean",
"description": "Turn on debug logging to print debug message generated by AWS SAM CLI and display timestamps."
},
"profile": {
"title": "profile",
"type": "string",
"description": "Select a specific profile from your credential file to get AWS credentials."
},
"region": {
"title": "region",
"type": "string",
"description": "Set the AWS Region of the service. (e.g. us-east-1)"
}
}
}
},
"required": [
Expand Down Expand Up @@ -389,7 +508,7 @@
},
"pipeline_bootstrap": {
"title": "Pipeline Bootstrap command",
"description": "This command generates the required AWS infrastructure resources to connect to your CI/CD system.\nThis step must be run for each deployment stage in your pipeline, prior to running the sam pipline init command.",
"description": "This command generates the required AWS infrastructure resources to connect to your CI/CD system.\nThis step must be run for each deployment stage in your pipeline, prior to running the sam pipeline init command.",
"properties": {
"parameters": {
"title": "Parameters for the pipeline bootstrap command",
Expand Down
4 changes: 2 additions & 2 deletions schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class SamCliCommandSchema:
def to_schema(self) -> dict:
"""Return the JSON schema representation of the SAM CLI command."""
COMMANDS_TO_EXCLUDE = [ # TEMPORARY: for use only while generating piece-by-piece
"deploy",
"build",
# "deploy",
# "build",
"local",
"validate",
"package",
Expand Down