Skip to content

API Reference

Constructs

OpenApiAsyncDefinition

The OpenAPI Spec.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.OpenApiAsyncDefinition(
  project: Project,
  open_api_options: OpenApiModelOptions,
  handler_languages: typing.List[Language] = None
)
Name Type Description
project projen.Project No description.
open_api_options OpenApiModelOptions Options for the openapi model.
handler_languages typing.List[Language] The languages users have specified for handler projects (if any).

projectRequired
  • Type: projen.Project

open_api_optionsRequired

Options for the openapi model.


handler_languagesOptional

The languages users have specified for handler projects (if any).


Methods

Name Description
to_string Returns a string representation of this construct.
post_synthesize Called after synthesis.
pre_synthesize Called before synthesis.
synthesize Synthesizes files to the project output directory.

to_string
def to_string() -> str

Returns a string representation of this construct.

post_synthesize
def post_synthesize() -> None

Called after synthesis.

Order is not guaranteed.

pre_synthesize
def pre_synthesize() -> None

Called before synthesis.

synthesize
def synthesize() -> None

Synthesizes files to the project output directory.

Static Functions

Name Description
is_construct Checks if x is a construct.
is_component Test whether the given construct is a component.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.OpenApiAsyncDefinition.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


is_component
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.OpenApiAsyncDefinition.is_component(
  x: typing.Any
)

Test whether the given construct is a component.

xRequired
  • Type: typing.Any

Properties

Name Type Description
node constructs.Node The tree node.
project projen.Project No description.
open_api_specification_path str Path to the root OpenAPI specification file.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


projectRequired
project: Project
  • Type: projen.Project

open_api_specification_pathRequired
open_api_specification_path: str
  • Type: str

Path to the root OpenAPI specification file.


OpenApiAsyncModelProject

Project for defining an OpenAPI model for a WebSocket API.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.OpenApiAsyncModelProject(
  name: str,
  commit_generated: bool = None,
  git_ignore_options: IgnoreFileOptions = None,
  git_options: GitOptions = None,
  logging: LoggerOptions = None,
  outdir: str = None,
  parent: Project = None,
  projen_command: str = None,
  projenrc_json: bool = None,
  projenrc_json_options: ProjenrcJsonOptions = None,
  renovatebot: bool = None,
  renovatebot_options: RenovatebotOptions = None,
  open_api_options: OpenApiModelOptions,
  handler_languages: typing.List[Language] = None,
  parsed_spec_file: str,
  async_api_spec_file: str
)
Name Type Description
name str This is the name of your project.
commit_generated bool Whether to commit the managed files by default.
git_ignore_options projen.IgnoreFileOptions Configuration options for .gitignore file.
git_options projen.GitOptions Configuration options for git.
logging projen.LoggerOptions Configure logging options such as verbosity.
outdir str The root directory of the project.
parent projen.Project The parent project, if this project is part of a bigger project.
projen_command str The shell command to use in order to run the projen CLI.
projenrc_json bool Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.
projenrc_json_options projen.ProjenrcJsonOptions Options for .projenrc.json.
renovatebot bool Use renovatebot to handle dependency upgrades.
renovatebot_options projen.RenovatebotOptions Options for renovatebot.
open_api_options OpenApiModelOptions Options for the openapi model.
handler_languages typing.List[Language] The languages users have specified for handler projects (if any).
parsed_spec_file str Path of the parsed/bundled OpenAPI specification (relative to the project root).
async_api_spec_file str Path to the generated AsyncAPI specification (relative to the project root).

nameRequired
  • Type: str
  • Default: $BASEDIR

This is the name of your project.


commit_generatedOptional
  • Type: bool
  • Default: true

Whether to commit the managed files by default.


git_ignore_optionsOptional
  • Type: projen.IgnoreFileOptions

Configuration options for .gitignore file.


git_optionsOptional
  • Type: projen.GitOptions

Configuration options for git.


loggingOptional
  • Type: projen.LoggerOptions
  • Default: {}

Configure logging options such as verbosity.


outdirOptional
  • Type: str
  • Default: "."

The root directory of the project.

Relative to this directory, all files are synthesized.

If this project has a parent, this directory is relative to the parent directory and it cannot be the same as the parent or any of it's other subprojects.


parentOptional
  • Type: projen.Project

The parent project, if this project is part of a bigger project.


projen_commandOptional
  • Type: str
  • Default: "npx projen"

The shell command to use in order to run the projen CLI.

Can be used to customize in special environments.


projenrc_jsonOptional
  • Type: bool
  • Default: false

Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.


projenrc_json_optionsOptional
  • Type: projen.ProjenrcJsonOptions
  • Default: default options

Options for .projenrc.json.


renovatebotOptional
  • Type: bool
  • Default: false

Use renovatebot to handle dependency upgrades.


renovatebot_optionsOptional
  • Type: projen.RenovatebotOptions
  • Default: default options

Options for renovatebot.


open_api_optionsRequired

Options for the openapi model.


handler_languagesOptional

The languages users have specified for handler projects (if any).


parsed_spec_fileRequired
  • Type: str

Path of the parsed/bundled OpenAPI specification (relative to the project root).


async_api_spec_fileRequired
  • Type: str

Path to the generated AsyncAPI specification (relative to the project root).


Methods

Name Description
to_string Returns a string representation of this construct.
add_exclude_from_cleanup Exclude the matching files from pre-synth cleanup.
add_git_ignore Adds a .gitignore pattern.
add_package_ignore Exclude these files from the bundled package.
add_task Adds a new task to this project.
add_tip Prints a "tip" message during synthesis.
annotate_generated Consider a set of files as "generated".
post_synthesize Called after all components are synthesized.
pre_synthesize Called before all components are synthesized.
remove_task Removes a task from a project.
run_task_command Returns the shell command to execute in order to run a task.
synth Synthesize all project files into outdir.
try_find_file Finds a file at the specified relative path within this project and all its subprojects.
try_find_json_file Finds a json file by name.
try_find_object_file Finds an object file (like JsonFile, YamlFile, etc.) by name.
try_remove_file Finds a file at the specified relative path within this project and removes it.

to_string
def to_string() -> str

Returns a string representation of this construct.

add_exclude_from_cleanup
def add_exclude_from_cleanup(
  globs: str
) -> None

Exclude the matching files from pre-synth cleanup.

Can be used when, for example, some source files include the projen marker and we don't want them to be erased during synth.

globsRequired
  • Type: str

The glob patterns to match.


add_git_ignore
def add_git_ignore(
  pattern: str
) -> None

Adds a .gitignore pattern.

patternRequired
  • Type: str

The glob pattern to ignore.


add_package_ignore
def add_package_ignore(
  _pattern: str
) -> None

Exclude these files from the bundled package.

Implemented by project types based on the packaging mechanism. For example, NodeProject delegates this to .npmignore.

_patternRequired
  • Type: str

The glob pattern to exclude.


add_task
def add_task(
  name: str,
  condition: str = None,
  cwd: str = None,
  description: str = None,
  env: typing.Mapping[str] = None,
  required_env: typing.List[str] = None,
  args: typing.List[str] = None,
  exec: str = None,
  receive_args: bool = None,
  steps: typing.List[TaskStep] = None
) -> Task

Adds a new task to this project.

This will fail if the project already has a task with this name.

nameRequired
  • Type: str

The task name to add.


conditionOptional
  • Type: str

A shell command which determines if the this task should be executed.

If the program exits with a zero exit code, steps will be executed. A non-zero code means that task will be skipped.


cwdOptional
  • Type: str
  • Default: process.cwd()

The working directory for all steps in this task (unless overridden by the step).


descriptionOptional
  • Type: str
  • Default: the task name

The description of this build command.


envOptional
  • Type: typing.Mapping[str]
  • Default: {}

Defines environment variables for the execution of this task.

Values in this map will be evaluated in a shell, so you can do stuff like $(echo "foo").


required_envOptional
  • Type: typing.List[str]

A set of environment variables that must be defined in order to execute this task.

Task execution will fail if one of these is not defined.


argsOptional
  • Type: typing.List[str]
  • Default: no arguments are passed to the step

Should the provided exec shell command receive fixed args.

{@link TaskStepOptions.args }


execOptional
  • Type: str
  • Default: add steps using task.exec(command) or task.spawn(subtask)

Shell command to execute as the first command of the task.


receive_argsOptional
  • Type: bool
  • Default: false

Should the provided exec shell command receive args passed to the task.

{@link TaskStepOptions.receiveArgs }


stepsOptional
  • Type: typing.List[projen.TaskStep]

List of task steps to run.


~~add_tip~~
def add_tip(
  message: str
) -> None

Prints a "tip" message during synthesis.

messageRequired
  • Type: str

The message.


annotate_generated
def annotate_generated(
  _glob: str
) -> None

Consider a set of files as "generated".

This method is implemented by derived classes and used for example, to add git attributes to tell GitHub that certain files are generated.

_globRequired
  • Type: str

the glob pattern to match (could be a file path).


post_synthesize
def post_synthesize() -> None

Called after all components are synthesized.

Order is not guaranteed.

pre_synthesize
def pre_synthesize() -> None

Called before all components are synthesized.

remove_task
def remove_task(
  name: str
) -> Task

Removes a task from a project.

nameRequired
  • Type: str

The name of the task to remove.


run_task_command
def run_task_command(
  task: Task
) -> str

Returns the shell command to execute in order to run a task.

By default, this is npx projen@<version> <task>

taskRequired
  • Type: projen.Task

The task for which the command is required.


synth
def synth() -> None

Synthesize all project files into outdir.

  1. Call "this.preSynthesize()"
  2. Delete all generated files
  3. Synthesize all subprojects
  4. Synthesize all components of this project
  5. Call "postSynthesize()" for all components of this project
  6. Call "this.postSynthesize()"
try_find_file
def try_find_file(
  file_path: str
) -> FileBase

Finds a file at the specified relative path within this project and all its subprojects.

file_pathRequired
  • Type: str

The file path.

If this path is relative, it will be resolved from the root of this project.


~~try_find_json_file~~
def try_find_json_file(
  file_path: str
) -> JsonFile

Finds a json file by name.

file_pathRequired
  • Type: str

The file path.


try_find_object_file
def try_find_object_file(
  file_path: str
) -> ObjectFile

Finds an object file (like JsonFile, YamlFile, etc.) by name.

file_pathRequired
  • Type: str

The file path.


try_remove_file
def try_remove_file(
  file_path: str
) -> FileBase

Finds a file at the specified relative path within this project and removes it.

file_pathRequired
  • Type: str

The file path.

If this path is relative, it will be resolved from the root of this project.


Static Functions

Name Description
is_construct Checks if x is a construct.
is_project Test whether the given construct is a project.
of Find the closest ancestor project for given construct.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.OpenApiAsyncModelProject.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


is_project
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.OpenApiAsyncModelProject.is_project(
  x: typing.Any
)

Test whether the given construct is a project.

xRequired
  • Type: typing.Any

of
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.OpenApiAsyncModelProject.of(
  construct: IConstruct
)

Find the closest ancestor project for given construct.

When given a project, this it the project itself.

constructRequired
  • Type: constructs.IConstruct

Properties

Name Type Description
node constructs.Node The tree node.
build_task projen.Task No description.
commit_generated bool Whether to commit the managed files by default.
compile_task projen.Task No description.
components typing.List[projen.Component] Returns all the components within this project.
deps projen.Dependencies Project dependencies.
ejected bool Whether or not the project is being ejected.
files typing.List[projen.FileBase] All files in this project.
gitattributes projen.GitAttributesFile The .gitattributes file for this repository.
gitignore projen.IgnoreFile .gitignore.
logger projen.Logger Logging utilities.
name str Project name.
outdir str Absolute output directory of this project.
package_task projen.Task No description.
post_compile_task projen.Task No description.
pre_compile_task projen.Task No description.
project_build projen.ProjectBuild Manages the build process of the project.
projen_command str The command to use in order to run the projen CLI.
root projen.Project The root project.
subprojects typing.List[projen.Project] Returns all the subprojects within this project.
tasks projen.Tasks Project tasks.
test_task projen.Task No description.
default_task projen.Task This is the "default" task, the one that executes "projen".
init_project projen.InitProject The options used when this project is bootstrapped via projen new.
parent projen.Project A parent project.
api_name str Name of the API.
definition OpenApiAsyncDefinition OpenAPI specification component.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


build_taskRequired
build_task: Task
  • Type: projen.Task

commit_generatedRequired
commit_generated: bool
  • Type: bool

Whether to commit the managed files by default.


compile_taskRequired
compile_task: Task
  • Type: projen.Task

componentsRequired
components: typing.List[Component]
  • Type: typing.List[projen.Component]

Returns all the components within this project.


depsRequired
deps: Dependencies
  • Type: projen.Dependencies

Project dependencies.


ejectedRequired
ejected: bool
  • Type: bool

Whether or not the project is being ejected.


filesRequired
files: typing.List[FileBase]
  • Type: typing.List[projen.FileBase]

All files in this project.


gitattributesRequired
gitattributes: GitAttributesFile
  • Type: projen.GitAttributesFile

The .gitattributes file for this repository.


gitignoreRequired
gitignore: IgnoreFile
  • Type: projen.IgnoreFile

.gitignore.


loggerRequired
logger: Logger
  • Type: projen.Logger

Logging utilities.


nameRequired
name: str
  • Type: str

Project name.


outdirRequired
outdir: str
  • Type: str

Absolute output directory of this project.


package_taskRequired
package_task: Task
  • Type: projen.Task

post_compile_taskRequired
post_compile_task: Task
  • Type: projen.Task

pre_compile_taskRequired
pre_compile_task: Task
  • Type: projen.Task

project_buildRequired
project_build: ProjectBuild
  • Type: projen.ProjectBuild

Manages the build process of the project.


projen_commandRequired
projen_command: str
  • Type: str

The command to use in order to run the projen CLI.


rootRequired
root: Project
  • Type: projen.Project

The root project.


subprojectsRequired
subprojects: typing.List[Project]
  • Type: typing.List[projen.Project]

Returns all the subprojects within this project.


tasksRequired
tasks: Tasks
  • Type: projen.Tasks

Project tasks.


test_taskRequired
test_task: Task
  • Type: projen.Task

default_taskOptional
default_task: Task
  • Type: projen.Task

This is the "default" task, the one that executes "projen".

Undefined if the project is being ejected.


init_projectOptional
init_project: InitProject
  • Type: projen.InitProject

The options used when this project is bootstrapped via projen new.

It includes the original set of options passed to the CLI and also the JSII FQN of the project type.


parentOptional
parent: Project
  • Type: projen.Project

A parent project.

If undefined, this is the root project.


api_nameRequired
api_name: str
  • Type: str

Name of the API.


definitionRequired
definition: OpenApiAsyncDefinition

OpenAPI specification component.


Constants

Name Type Description
DEFAULT_TASK str The name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
DEFAULT_TASK: str
  • Type: str

The name of the default task (the task executed when projen is run without arguments).

Normally this task should synthesize the project files.


OpenApiDefinition

The OpenAPI Spec.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.OpenApiDefinition(
  project: Project,
  open_api_options: OpenApiModelOptions,
  handler_languages: typing.List[Language] = None
)
Name Type Description
project projen.Project No description.
open_api_options OpenApiModelOptions Options for the openapi model.
handler_languages typing.List[Language] The languages users have specified for handler projects (if any).

projectRequired
  • Type: projen.Project

open_api_optionsRequired

Options for the openapi model.


handler_languagesOptional

The languages users have specified for handler projects (if any).


Methods

Name Description
to_string Returns a string representation of this construct.
post_synthesize Called after synthesis.
pre_synthesize Called before synthesis.
synthesize Synthesizes files to the project output directory.

to_string
def to_string() -> str

Returns a string representation of this construct.

post_synthesize
def post_synthesize() -> None

Called after synthesis.

Order is not guaranteed.

pre_synthesize
def pre_synthesize() -> None

Called before synthesis.

synthesize
def synthesize() -> None

Synthesizes files to the project output directory.

Static Functions

Name Description
is_construct Checks if x is a construct.
is_component Test whether the given construct is a component.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.OpenApiDefinition.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


is_component
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.OpenApiDefinition.is_component(
  x: typing.Any
)

Test whether the given construct is a component.

xRequired
  • Type: typing.Any

Properties

Name Type Description
node constructs.Node The tree node.
project projen.Project No description.
open_api_specification_path str Path to the root OpenAPI specification file.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


projectRequired
project: Project
  • Type: projen.Project

open_api_specification_pathRequired
open_api_specification_path: str
  • Type: str

Path to the root OpenAPI specification file.


OpenApiModelProject

Project for defining an OpenAPI model for a REST API.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.OpenApiModelProject(
  name: str,
  commit_generated: bool = None,
  git_ignore_options: IgnoreFileOptions = None,
  git_options: GitOptions = None,
  logging: LoggerOptions = None,
  outdir: str = None,
  parent: Project = None,
  projen_command: str = None,
  projenrc_json: bool = None,
  projenrc_json_options: ProjenrcJsonOptions = None,
  renovatebot: bool = None,
  renovatebot_options: RenovatebotOptions = None,
  open_api_options: OpenApiModelOptions,
  handler_languages: typing.List[Language] = None,
  parsed_spec_file: str
)
Name Type Description
name str This is the name of your project.
commit_generated bool Whether to commit the managed files by default.
git_ignore_options projen.IgnoreFileOptions Configuration options for .gitignore file.
git_options projen.GitOptions Configuration options for git.
logging projen.LoggerOptions Configure logging options such as verbosity.
outdir str The root directory of the project.
parent projen.Project The parent project, if this project is part of a bigger project.
projen_command str The shell command to use in order to run the projen CLI.
projenrc_json bool Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.
projenrc_json_options projen.ProjenrcJsonOptions Options for .projenrc.json.
renovatebot bool Use renovatebot to handle dependency upgrades.
renovatebot_options projen.RenovatebotOptions Options for renovatebot.
open_api_options OpenApiModelOptions Options for the openapi model.
handler_languages typing.List[Language] The languages users have specified for handler projects (if any).
parsed_spec_file str Path of the parsed/bundled OpenAPI specification (relative to the project root).

nameRequired
  • Type: str
  • Default: $BASEDIR

This is the name of your project.


commit_generatedOptional
  • Type: bool
  • Default: true

Whether to commit the managed files by default.


git_ignore_optionsOptional
  • Type: projen.IgnoreFileOptions

Configuration options for .gitignore file.


git_optionsOptional
  • Type: projen.GitOptions

Configuration options for git.


loggingOptional
  • Type: projen.LoggerOptions
  • Default: {}

Configure logging options such as verbosity.


outdirOptional
  • Type: str
  • Default: "."

The root directory of the project.

Relative to this directory, all files are synthesized.

If this project has a parent, this directory is relative to the parent directory and it cannot be the same as the parent or any of it's other subprojects.


parentOptional
  • Type: projen.Project

The parent project, if this project is part of a bigger project.


projen_commandOptional
  • Type: str
  • Default: "npx projen"

The shell command to use in order to run the projen CLI.

Can be used to customize in special environments.


projenrc_jsonOptional
  • Type: bool
  • Default: false

Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.


projenrc_json_optionsOptional
  • Type: projen.ProjenrcJsonOptions
  • Default: default options

Options for .projenrc.json.


renovatebotOptional
  • Type: bool
  • Default: false

Use renovatebot to handle dependency upgrades.


renovatebot_optionsOptional
  • Type: projen.RenovatebotOptions
  • Default: default options

Options for renovatebot.


open_api_optionsRequired

Options for the openapi model.


handler_languagesOptional

The languages users have specified for handler projects (if any).


parsed_spec_fileRequired
  • Type: str

Path of the parsed/bundled OpenAPI specification (relative to the project root).


Methods

Name Description
to_string Returns a string representation of this construct.
add_exclude_from_cleanup Exclude the matching files from pre-synth cleanup.
add_git_ignore Adds a .gitignore pattern.
add_package_ignore Exclude these files from the bundled package.
add_task Adds a new task to this project.
add_tip Prints a "tip" message during synthesis.
annotate_generated Consider a set of files as "generated".
post_synthesize Called after all components are synthesized.
pre_synthesize Called before all components are synthesized.
remove_task Removes a task from a project.
run_task_command Returns the shell command to execute in order to run a task.
synth Synthesize all project files into outdir.
try_find_file Finds a file at the specified relative path within this project and all its subprojects.
try_find_json_file Finds a json file by name.
try_find_object_file Finds an object file (like JsonFile, YamlFile, etc.) by name.
try_remove_file Finds a file at the specified relative path within this project and removes it.

to_string
def to_string() -> str

Returns a string representation of this construct.

add_exclude_from_cleanup
def add_exclude_from_cleanup(
  globs: str
) -> None

Exclude the matching files from pre-synth cleanup.

Can be used when, for example, some source files include the projen marker and we don't want them to be erased during synth.

globsRequired
  • Type: str

The glob patterns to match.


add_git_ignore
def add_git_ignore(
  pattern: str
) -> None

Adds a .gitignore pattern.

patternRequired
  • Type: str

The glob pattern to ignore.


add_package_ignore
def add_package_ignore(
  _pattern: str
) -> None

Exclude these files from the bundled package.

Implemented by project types based on the packaging mechanism. For example, NodeProject delegates this to .npmignore.

_patternRequired
  • Type: str

The glob pattern to exclude.


add_task
def add_task(
  name: str,
  condition: str = None,
  cwd: str = None,
  description: str = None,
  env: typing.Mapping[str] = None,
  required_env: typing.List[str] = None,
  args: typing.List[str] = None,
  exec: str = None,
  receive_args: bool = None,
  steps: typing.List[TaskStep] = None
) -> Task

Adds a new task to this project.

This will fail if the project already has a task with this name.

nameRequired
  • Type: str

The task name to add.


conditionOptional
  • Type: str

A shell command which determines if the this task should be executed.

If the program exits with a zero exit code, steps will be executed. A non-zero code means that task will be skipped.


cwdOptional
  • Type: str
  • Default: process.cwd()

The working directory for all steps in this task (unless overridden by the step).


descriptionOptional
  • Type: str
  • Default: the task name

The description of this build command.


envOptional
  • Type: typing.Mapping[str]
  • Default: {}

Defines environment variables for the execution of this task.

Values in this map will be evaluated in a shell, so you can do stuff like $(echo "foo").


required_envOptional
  • Type: typing.List[str]

A set of environment variables that must be defined in order to execute this task.

Task execution will fail if one of these is not defined.


argsOptional
  • Type: typing.List[str]
  • Default: no arguments are passed to the step

Should the provided exec shell command receive fixed args.

{@link TaskStepOptions.args }


execOptional
  • Type: str
  • Default: add steps using task.exec(command) or task.spawn(subtask)

Shell command to execute as the first command of the task.


receive_argsOptional
  • Type: bool
  • Default: false

Should the provided exec shell command receive args passed to the task.

{@link TaskStepOptions.receiveArgs }


stepsOptional
  • Type: typing.List[projen.TaskStep]

List of task steps to run.


~~add_tip~~
def add_tip(
  message: str
) -> None

Prints a "tip" message during synthesis.

messageRequired
  • Type: str

The message.


annotate_generated
def annotate_generated(
  _glob: str
) -> None

Consider a set of files as "generated".

This method is implemented by derived classes and used for example, to add git attributes to tell GitHub that certain files are generated.

_globRequired
  • Type: str

the glob pattern to match (could be a file path).


post_synthesize
def post_synthesize() -> None

Called after all components are synthesized.

Order is not guaranteed.

pre_synthesize
def pre_synthesize() -> None

Called before all components are synthesized.

remove_task
def remove_task(
  name: str
) -> Task

Removes a task from a project.

nameRequired
  • Type: str

The name of the task to remove.


run_task_command
def run_task_command(
  task: Task
) -> str

Returns the shell command to execute in order to run a task.

By default, this is npx projen@<version> <task>

taskRequired
  • Type: projen.Task

The task for which the command is required.


synth
def synth() -> None

Synthesize all project files into outdir.

  1. Call "this.preSynthesize()"
  2. Delete all generated files
  3. Synthesize all subprojects
  4. Synthesize all components of this project
  5. Call "postSynthesize()" for all components of this project
  6. Call "this.postSynthesize()"
try_find_file
def try_find_file(
  file_path: str
) -> FileBase

Finds a file at the specified relative path within this project and all its subprojects.

file_pathRequired
  • Type: str

The file path.

If this path is relative, it will be resolved from the root of this project.


~~try_find_json_file~~
def try_find_json_file(
  file_path: str
) -> JsonFile

Finds a json file by name.

file_pathRequired
  • Type: str

The file path.


try_find_object_file
def try_find_object_file(
  file_path: str
) -> ObjectFile

Finds an object file (like JsonFile, YamlFile, etc.) by name.

file_pathRequired
  • Type: str

The file path.


try_remove_file
def try_remove_file(
  file_path: str
) -> FileBase

Finds a file at the specified relative path within this project and removes it.

file_pathRequired
  • Type: str

The file path.

If this path is relative, it will be resolved from the root of this project.


Static Functions

Name Description
is_construct Checks if x is a construct.
is_project Test whether the given construct is a project.
of Find the closest ancestor project for given construct.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.OpenApiModelProject.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


is_project
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.OpenApiModelProject.is_project(
  x: typing.Any
)

Test whether the given construct is a project.

xRequired
  • Type: typing.Any

of
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.OpenApiModelProject.of(
  construct: IConstruct
)

Find the closest ancestor project for given construct.

When given a project, this it the project itself.

constructRequired
  • Type: constructs.IConstruct

Properties

Name Type Description
node constructs.Node The tree node.
build_task projen.Task No description.
commit_generated bool Whether to commit the managed files by default.
compile_task projen.Task No description.
components typing.List[projen.Component] Returns all the components within this project.
deps projen.Dependencies Project dependencies.
ejected bool Whether or not the project is being ejected.
files typing.List[projen.FileBase] All files in this project.
gitattributes projen.GitAttributesFile The .gitattributes file for this repository.
gitignore projen.IgnoreFile .gitignore.
logger projen.Logger Logging utilities.
name str Project name.
outdir str Absolute output directory of this project.
package_task projen.Task No description.
post_compile_task projen.Task No description.
pre_compile_task projen.Task No description.
project_build projen.ProjectBuild Manages the build process of the project.
projen_command str The command to use in order to run the projen CLI.
root projen.Project The root project.
subprojects typing.List[projen.Project] Returns all the subprojects within this project.
tasks projen.Tasks Project tasks.
test_task projen.Task No description.
default_task projen.Task This is the "default" task, the one that executes "projen".
init_project projen.InitProject The options used when this project is bootstrapped via projen new.
parent projen.Project A parent project.
api_name str Name of the API.
definition OpenApiDefinition OpenAPI specification component.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


build_taskRequired
build_task: Task
  • Type: projen.Task

commit_generatedRequired
commit_generated: bool
  • Type: bool

Whether to commit the managed files by default.


compile_taskRequired
compile_task: Task
  • Type: projen.Task

componentsRequired
components: typing.List[Component]
  • Type: typing.List[projen.Component]

Returns all the components within this project.


depsRequired
deps: Dependencies
  • Type: projen.Dependencies

Project dependencies.


ejectedRequired
ejected: bool
  • Type: bool

Whether or not the project is being ejected.


filesRequired
files: typing.List[FileBase]
  • Type: typing.List[projen.FileBase]

All files in this project.


gitattributesRequired
gitattributes: GitAttributesFile
  • Type: projen.GitAttributesFile

The .gitattributes file for this repository.


gitignoreRequired
gitignore: IgnoreFile
  • Type: projen.IgnoreFile

.gitignore.


loggerRequired
logger: Logger
  • Type: projen.Logger

Logging utilities.


nameRequired
name: str
  • Type: str

Project name.


outdirRequired
outdir: str
  • Type: str

Absolute output directory of this project.


package_taskRequired
package_task: Task
  • Type: projen.Task

post_compile_taskRequired
post_compile_task: Task
  • Type: projen.Task

pre_compile_taskRequired
pre_compile_task: Task
  • Type: projen.Task

project_buildRequired
project_build: ProjectBuild
  • Type: projen.ProjectBuild

Manages the build process of the project.


projen_commandRequired
projen_command: str
  • Type: str

The command to use in order to run the projen CLI.


rootRequired
root: Project
  • Type: projen.Project

The root project.


subprojectsRequired
subprojects: typing.List[Project]
  • Type: typing.List[projen.Project]

Returns all the subprojects within this project.


tasksRequired
tasks: Tasks
  • Type: projen.Tasks

Project tasks.


test_taskRequired
test_task: Task
  • Type: projen.Task

default_taskOptional
default_task: Task
  • Type: projen.Task

This is the "default" task, the one that executes "projen".

Undefined if the project is being ejected.


init_projectOptional
init_project: InitProject
  • Type: projen.InitProject

The options used when this project is bootstrapped via projen new.

It includes the original set of options passed to the CLI and also the JSII FQN of the project type.


parentOptional
parent: Project
  • Type: projen.Project

A parent project.

If undefined, this is the root project.


api_nameRequired
api_name: str
  • Type: str

Name of the API.


definitionRequired
definition: OpenApiDefinition

OpenAPI specification component.


Constants

Name Type Description
DEFAULT_TASK str The name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
DEFAULT_TASK: str
  • Type: str

The name of the default task (the task executed when projen is run without arguments).

Normally this task should synthesize the project files.


OpenApiProjectDefinition

The OpenAPI Spec.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.OpenApiProjectDefinition(
  project: Project,
  open_api_options: OpenApiModelOptions,
  handler_languages: typing.List[Language] = None
)
Name Type Description
project projen.Project No description.
open_api_options OpenApiModelOptions Options for the openapi model.
handler_languages typing.List[Language] The languages users have specified for handler projects (if any).

projectRequired
  • Type: projen.Project

open_api_optionsRequired

Options for the openapi model.


handler_languagesOptional

The languages users have specified for handler projects (if any).


Methods

Name Description
to_string Returns a string representation of this construct.
post_synthesize Called after synthesis.
pre_synthesize Called before synthesis.
synthesize Synthesizes files to the project output directory.

to_string
def to_string() -> str

Returns a string representation of this construct.

post_synthesize
def post_synthesize() -> None

Called after synthesis.

Order is not guaranteed.

pre_synthesize
def pre_synthesize() -> None

Called before synthesis.

synthesize
def synthesize() -> None

Synthesizes files to the project output directory.

Static Functions

Name Description
is_construct Checks if x is a construct.
is_component Test whether the given construct is a component.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.OpenApiProjectDefinition.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


is_component
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.OpenApiProjectDefinition.is_component(
  x: typing.Any
)

Test whether the given construct is a component.

xRequired
  • Type: typing.Any

Properties

Name Type Description
node constructs.Node The tree node.
project projen.Project No description.
open_api_specification_path str Path to the root OpenAPI specification file.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


projectRequired
project: Project
  • Type: projen.Project

open_api_specification_pathRequired
open_api_specification_path: str
  • Type: str

Path to the root OpenAPI specification file.


SmithyAsyncModelProject

Smithy model project for a WebSocket API.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyAsyncModelProject(
  name: str,
  commit_generated: bool = None,
  git_ignore_options: IgnoreFileOptions = None,
  git_options: GitOptions = None,
  logging: LoggerOptions = None,
  outdir: str = None,
  parent: Project = None,
  projen_command: str = None,
  projenrc_json: bool = None,
  projenrc_json_options: ProjenrcJsonOptions = None,
  renovatebot: bool = None,
  renovatebot_options: RenovatebotOptions = None,
  smithy_options: SmithyModelOptions,
  handler_languages: typing.List[Language] = None,
  parsed_spec_file: str,
  async_api_spec_file: str
)
Name Type Description
name str This is the name of your project.
commit_generated bool Whether to commit the managed files by default.
git_ignore_options projen.IgnoreFileOptions Configuration options for .gitignore file.
git_options projen.GitOptions Configuration options for git.
logging projen.LoggerOptions Configure logging options such as verbosity.
outdir str The root directory of the project.
parent projen.Project The parent project, if this project is part of a bigger project.
projen_command str The shell command to use in order to run the projen CLI.
projenrc_json bool Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.
projenrc_json_options projen.ProjenrcJsonOptions Options for .projenrc.json.
renovatebot bool Use renovatebot to handle dependency upgrades.
renovatebot_options projen.RenovatebotOptions Options for renovatebot.
smithy_options SmithyModelOptions Smithy engine options.
handler_languages typing.List[Language] The languages users have specified for handler projects (if any).
parsed_spec_file str Path of the parsed/bundled OpenAPI specification (relative to the project root).
async_api_spec_file str Path to the generated AsyncAPI specification (relative to the project root).

nameRequired
  • Type: str
  • Default: $BASEDIR

This is the name of your project.


commit_generatedOptional
  • Type: bool
  • Default: true

Whether to commit the managed files by default.


git_ignore_optionsOptional
  • Type: projen.IgnoreFileOptions

Configuration options for .gitignore file.


git_optionsOptional
  • Type: projen.GitOptions

Configuration options for git.


loggingOptional
  • Type: projen.LoggerOptions
  • Default: {}

Configure logging options such as verbosity.


outdirOptional
  • Type: str
  • Default: "."

The root directory of the project.

Relative to this directory, all files are synthesized.

If this project has a parent, this directory is relative to the parent directory and it cannot be the same as the parent or any of it's other subprojects.


parentOptional
  • Type: projen.Project

The parent project, if this project is part of a bigger project.


projen_commandOptional
  • Type: str
  • Default: "npx projen"

The shell command to use in order to run the projen CLI.

Can be used to customize in special environments.


projenrc_jsonOptional
  • Type: bool
  • Default: false

Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.


projenrc_json_optionsOptional
  • Type: projen.ProjenrcJsonOptions
  • Default: default options

Options for .projenrc.json.


renovatebotOptional
  • Type: bool
  • Default: false

Use renovatebot to handle dependency upgrades.


renovatebot_optionsOptional
  • Type: projen.RenovatebotOptions
  • Default: default options

Options for renovatebot.


smithy_optionsRequired

Smithy engine options.


handler_languagesOptional

The languages users have specified for handler projects (if any).


parsed_spec_fileRequired
  • Type: str

Path of the parsed/bundled OpenAPI specification (relative to the project root).


async_api_spec_fileRequired
  • Type: str

Path to the generated AsyncAPI specification (relative to the project root).


Methods

Name Description
to_string Returns a string representation of this construct.
add_exclude_from_cleanup Exclude the matching files from pre-synth cleanup.
add_git_ignore Adds a .gitignore pattern.
add_package_ignore Exclude these files from the bundled package.
add_task Adds a new task to this project.
add_tip Prints a "tip" message during synthesis.
annotate_generated Consider a set of files as "generated".
post_synthesize Called after all components are synthesized.
pre_synthesize Called before all components are synthesized.
remove_task Removes a task from a project.
run_task_command Returns the shell command to execute in order to run a task.
synth Synthesize all project files into outdir.
try_find_file Finds a file at the specified relative path within this project and all its subprojects.
try_find_json_file Finds a json file by name.
try_find_object_file Finds an object file (like JsonFile, YamlFile, etc.) by name.
try_remove_file Finds a file at the specified relative path within this project and removes it.
add_smithy_deps Add a dependency on other smithy projects.
smithy_project_definition Returns the smithy project definition.

to_string
def to_string() -> str

Returns a string representation of this construct.

add_exclude_from_cleanup
def add_exclude_from_cleanup(
  globs: str
) -> None

Exclude the matching files from pre-synth cleanup.

Can be used when, for example, some source files include the projen marker and we don't want them to be erased during synth.

globsRequired
  • Type: str

The glob patterns to match.


add_git_ignore
def add_git_ignore(
  pattern: str
) -> None

Adds a .gitignore pattern.

patternRequired
  • Type: str

The glob pattern to ignore.


add_package_ignore
def add_package_ignore(
  _pattern: str
) -> None

Exclude these files from the bundled package.

Implemented by project types based on the packaging mechanism. For example, NodeProject delegates this to .npmignore.

_patternRequired
  • Type: str

The glob pattern to exclude.


add_task
def add_task(
  name: str,
  condition: str = None,
  cwd: str = None,
  description: str = None,
  env: typing.Mapping[str] = None,
  required_env: typing.List[str] = None,
  args: typing.List[str] = None,
  exec: str = None,
  receive_args: bool = None,
  steps: typing.List[TaskStep] = None
) -> Task

Adds a new task to this project.

This will fail if the project already has a task with this name.

nameRequired
  • Type: str

The task name to add.


conditionOptional
  • Type: str

A shell command which determines if the this task should be executed.

If the program exits with a zero exit code, steps will be executed. A non-zero code means that task will be skipped.


cwdOptional
  • Type: str
  • Default: process.cwd()

The working directory for all steps in this task (unless overridden by the step).


descriptionOptional
  • Type: str
  • Default: the task name

The description of this build command.


envOptional
  • Type: typing.Mapping[str]
  • Default: {}

Defines environment variables for the execution of this task.

Values in this map will be evaluated in a shell, so you can do stuff like $(echo "foo").


required_envOptional
  • Type: typing.List[str]

A set of environment variables that must be defined in order to execute this task.

Task execution will fail if one of these is not defined.


argsOptional
  • Type: typing.List[str]
  • Default: no arguments are passed to the step

Should the provided exec shell command receive fixed args.

{@link TaskStepOptions.args }


execOptional
  • Type: str
  • Default: add steps using task.exec(command) or task.spawn(subtask)

Shell command to execute as the first command of the task.


receive_argsOptional
  • Type: bool
  • Default: false

Should the provided exec shell command receive args passed to the task.

{@link TaskStepOptions.receiveArgs }


stepsOptional
  • Type: typing.List[projen.TaskStep]

List of task steps to run.


~~add_tip~~
def add_tip(
  message: str
) -> None

Prints a "tip" message during synthesis.

messageRequired
  • Type: str

The message.


annotate_generated
def annotate_generated(
  _glob: str
) -> None

Consider a set of files as "generated".

This method is implemented by derived classes and used for example, to add git attributes to tell GitHub that certain files are generated.

_globRequired
  • Type: str

the glob pattern to match (could be a file path).


post_synthesize
def post_synthesize() -> None

Called after all components are synthesized.

Order is not guaranteed.

pre_synthesize
def pre_synthesize() -> None

Called before all components are synthesized.

remove_task
def remove_task(
  name: str
) -> Task

Removes a task from a project.

nameRequired
  • Type: str

The name of the task to remove.


run_task_command
def run_task_command(
  task: Task
) -> str

Returns the shell command to execute in order to run a task.

By default, this is npx projen@<version> <task>

taskRequired
  • Type: projen.Task

The task for which the command is required.


synth
def synth() -> None

Synthesize all project files into outdir.

  1. Call "this.preSynthesize()"
  2. Delete all generated files
  3. Synthesize all subprojects
  4. Synthesize all components of this project
  5. Call "postSynthesize()" for all components of this project
  6. Call "this.postSynthesize()"
try_find_file
def try_find_file(
  file_path: str
) -> FileBase

Finds a file at the specified relative path within this project and all its subprojects.

file_pathRequired
  • Type: str

The file path.

If this path is relative, it will be resolved from the root of this project.


~~try_find_json_file~~
def try_find_json_file(
  file_path: str
) -> JsonFile

Finds a json file by name.

file_pathRequired
  • Type: str

The file path.


try_find_object_file
def try_find_object_file(
  file_path: str
) -> ObjectFile

Finds an object file (like JsonFile, YamlFile, etc.) by name.

file_pathRequired
  • Type: str

The file path.


try_remove_file
def try_remove_file(
  file_path: str
) -> FileBase

Finds a file at the specified relative path within this project and removes it.

file_pathRequired
  • Type: str

The file path.

If this path is relative, it will be resolved from the root of this project.


add_smithy_deps
def add_smithy_deps(
  deps: SmithyBaseProject
) -> None

Add a dependency on other smithy projects.

depsRequired

smithy_project_definition
def smithy_project_definition() -> SmithyProjectDefinition

Returns the smithy project definition.

Static Functions

Name Description
is_construct Checks if x is a construct.
is_project Test whether the given construct is a project.
of Find the closest ancestor project for given construct.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyAsyncModelProject.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


is_project
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyAsyncModelProject.is_project(
  x: typing.Any
)

Test whether the given construct is a project.

xRequired
  • Type: typing.Any

of
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyAsyncModelProject.of(
  construct: IConstruct
)

Find the closest ancestor project for given construct.

When given a project, this it the project itself.

constructRequired
  • Type: constructs.IConstruct

Properties

Name Type Description
node constructs.Node The tree node.
build_task projen.Task No description.
commit_generated bool Whether to commit the managed files by default.
compile_task projen.Task No description.
components typing.List[projen.Component] Returns all the components within this project.
deps projen.Dependencies Project dependencies.
ejected bool Whether or not the project is being ejected.
files typing.List[projen.FileBase] All files in this project.
gitattributes projen.GitAttributesFile The .gitattributes file for this repository.
gitignore projen.IgnoreFile .gitignore.
logger projen.Logger Logging utilities.
name str Project name.
outdir str Absolute output directory of this project.
package_task projen.Task No description.
post_compile_task projen.Task No description.
pre_compile_task projen.Task No description.
project_build projen.ProjectBuild Manages the build process of the project.
projen_command str The command to use in order to run the projen CLI.
root projen.Project The root project.
subprojects typing.List[projen.Project] Returns all the subprojects within this project.
tasks projen.Tasks Project tasks.
test_task projen.Task No description.
default_task projen.Task This is the "default" task, the one that executes "projen".
init_project projen.InitProject The options used when this project is bootstrapped via projen new.
parent projen.Project A parent project.
api_name str Name of the API.
definition SmithyServiceProjectDefinition Smithy model and build settings.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


build_taskRequired
build_task: Task
  • Type: projen.Task

commit_generatedRequired
commit_generated: bool
  • Type: bool

Whether to commit the managed files by default.


compile_taskRequired
compile_task: Task
  • Type: projen.Task

componentsRequired
components: typing.List[Component]
  • Type: typing.List[projen.Component]

Returns all the components within this project.


depsRequired
deps: Dependencies
  • Type: projen.Dependencies

Project dependencies.


ejectedRequired
ejected: bool
  • Type: bool

Whether or not the project is being ejected.


filesRequired
files: typing.List[FileBase]
  • Type: typing.List[projen.FileBase]

All files in this project.


gitattributesRequired
gitattributes: GitAttributesFile
  • Type: projen.GitAttributesFile

The .gitattributes file for this repository.


gitignoreRequired
gitignore: IgnoreFile
  • Type: projen.IgnoreFile

.gitignore.


loggerRequired
logger: Logger
  • Type: projen.Logger

Logging utilities.


nameRequired
name: str
  • Type: str

Project name.


outdirRequired
outdir: str
  • Type: str

Absolute output directory of this project.


package_taskRequired
package_task: Task
  • Type: projen.Task

post_compile_taskRequired
post_compile_task: Task
  • Type: projen.Task

pre_compile_taskRequired
pre_compile_task: Task
  • Type: projen.Task

project_buildRequired
project_build: ProjectBuild
  • Type: projen.ProjectBuild

Manages the build process of the project.


projen_commandRequired
projen_command: str
  • Type: str

The command to use in order to run the projen CLI.


rootRequired
root: Project
  • Type: projen.Project

The root project.


subprojectsRequired
subprojects: typing.List[Project]
  • Type: typing.List[projen.Project]

Returns all the subprojects within this project.


tasksRequired
tasks: Tasks
  • Type: projen.Tasks

Project tasks.


test_taskRequired
test_task: Task
  • Type: projen.Task

default_taskOptional
default_task: Task
  • Type: projen.Task

This is the "default" task, the one that executes "projen".

Undefined if the project is being ejected.


init_projectOptional
init_project: InitProject
  • Type: projen.InitProject

The options used when this project is bootstrapped via projen new.

It includes the original set of options passed to the CLI and also the JSII FQN of the project type.


parentOptional
parent: Project
  • Type: projen.Project

A parent project.

If undefined, this is the root project.


api_nameRequired
api_name: str
  • Type: str

Name of the API.


definitionRequired
definition: SmithyServiceProjectDefinition

Smithy model and build settings.


Constants

Name Type Description
DEFAULT_TASK str The name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
DEFAULT_TASK: str
  • Type: str

The name of the default task (the task executed when projen is run without arguments).

Normally this task should synthesize the project files.


SmithyBaseProject

Base project for Smithy projects.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyBaseProject(
  name: str,
  commit_generated: bool = None,
  git_ignore_options: IgnoreFileOptions = None,
  git_options: GitOptions = None,
  logging: LoggerOptions = None,
  outdir: str = None,
  parent: Project = None,
  projen_command: str = None,
  projenrc_json: bool = None,
  projenrc_json_options: ProjenrcJsonOptions = None,
  renovatebot: bool = None,
  renovatebot_options: RenovatebotOptions = None
)
Name Type Description
name str This is the name of your project.
commit_generated bool Whether to commit the managed files by default.
git_ignore_options projen.IgnoreFileOptions Configuration options for .gitignore file.
git_options projen.GitOptions Configuration options for git.
logging projen.LoggerOptions Configure logging options such as verbosity.
outdir str The root directory of the project.
parent projen.Project The parent project, if this project is part of a bigger project.
projen_command str The shell command to use in order to run the projen CLI.
projenrc_json bool Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.
projenrc_json_options projen.ProjenrcJsonOptions Options for .projenrc.json.
renovatebot bool Use renovatebot to handle dependency upgrades.
renovatebot_options projen.RenovatebotOptions Options for renovatebot.

nameRequired
  • Type: str
  • Default: $BASEDIR

This is the name of your project.


commit_generatedOptional
  • Type: bool
  • Default: true

Whether to commit the managed files by default.


git_ignore_optionsOptional
  • Type: projen.IgnoreFileOptions

Configuration options for .gitignore file.


git_optionsOptional
  • Type: projen.GitOptions

Configuration options for git.


loggingOptional
  • Type: projen.LoggerOptions
  • Default: {}

Configure logging options such as verbosity.


outdirOptional
  • Type: str
  • Default: "."

The root directory of the project.

Relative to this directory, all files are synthesized.

If this project has a parent, this directory is relative to the parent directory and it cannot be the same as the parent or any of it's other subprojects.


parentOptional
  • Type: projen.Project

The parent project, if this project is part of a bigger project.


projen_commandOptional
  • Type: str
  • Default: "npx projen"

The shell command to use in order to run the projen CLI.

Can be used to customize in special environments.


projenrc_jsonOptional
  • Type: bool
  • Default: false

Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.


projenrc_json_optionsOptional
  • Type: projen.ProjenrcJsonOptions
  • Default: default options

Options for .projenrc.json.


renovatebotOptional
  • Type: bool
  • Default: false

Use renovatebot to handle dependency upgrades.


renovatebot_optionsOptional
  • Type: projen.RenovatebotOptions
  • Default: default options

Options for renovatebot.


Methods

Name Description
to_string Returns a string representation of this construct.
add_exclude_from_cleanup Exclude the matching files from pre-synth cleanup.
add_git_ignore Adds a .gitignore pattern.
add_package_ignore Exclude these files from the bundled package.
add_task Adds a new task to this project.
add_tip Prints a "tip" message during synthesis.
annotate_generated Consider a set of files as "generated".
post_synthesize Called after all components are synthesized.
pre_synthesize Called before all components are synthesized.
remove_task Removes a task from a project.
run_task_command Returns the shell command to execute in order to run a task.
synth Synthesize all project files into outdir.
try_find_file Finds a file at the specified relative path within this project and all its subprojects.
try_find_json_file Finds a json file by name.
try_find_object_file Finds an object file (like JsonFile, YamlFile, etc.) by name.
try_remove_file Finds a file at the specified relative path within this project and removes it.
add_smithy_deps Add a dependency on other smithy projects.
smithy_project_definition Returns the smithy project definition.

to_string
def to_string() -> str

Returns a string representation of this construct.

add_exclude_from_cleanup
def add_exclude_from_cleanup(
  globs: str
) -> None

Exclude the matching files from pre-synth cleanup.

Can be used when, for example, some source files include the projen marker and we don't want them to be erased during synth.

globsRequired
  • Type: str

The glob patterns to match.


add_git_ignore
def add_git_ignore(
  pattern: str
) -> None

Adds a .gitignore pattern.

patternRequired
  • Type: str

The glob pattern to ignore.


add_package_ignore
def add_package_ignore(
  _pattern: str
) -> None

Exclude these files from the bundled package.

Implemented by project types based on the packaging mechanism. For example, NodeProject delegates this to .npmignore.

_patternRequired
  • Type: str

The glob pattern to exclude.


add_task
def add_task(
  name: str,
  condition: str = None,
  cwd: str = None,
  description: str = None,
  env: typing.Mapping[str] = None,
  required_env: typing.List[str] = None,
  args: typing.List[str] = None,
  exec: str = None,
  receive_args: bool = None,
  steps: typing.List[TaskStep] = None
) -> Task

Adds a new task to this project.

This will fail if the project already has a task with this name.

nameRequired
  • Type: str

The task name to add.


conditionOptional
  • Type: str

A shell command which determines if the this task should be executed.

If the program exits with a zero exit code, steps will be executed. A non-zero code means that task will be skipped.


cwdOptional
  • Type: str
  • Default: process.cwd()

The working directory for all steps in this task (unless overridden by the step).


descriptionOptional
  • Type: str
  • Default: the task name

The description of this build command.


envOptional
  • Type: typing.Mapping[str]
  • Default: {}

Defines environment variables for the execution of this task.

Values in this map will be evaluated in a shell, so you can do stuff like $(echo "foo").


required_envOptional
  • Type: typing.List[str]

A set of environment variables that must be defined in order to execute this task.

Task execution will fail if one of these is not defined.


argsOptional
  • Type: typing.List[str]
  • Default: no arguments are passed to the step

Should the provided exec shell command receive fixed args.

{@link TaskStepOptions.args }


execOptional
  • Type: str
  • Default: add steps using task.exec(command) or task.spawn(subtask)

Shell command to execute as the first command of the task.


receive_argsOptional
  • Type: bool
  • Default: false

Should the provided exec shell command receive args passed to the task.

{@link TaskStepOptions.receiveArgs }


stepsOptional
  • Type: typing.List[projen.TaskStep]

List of task steps to run.


~~add_tip~~
def add_tip(
  message: str
) -> None

Prints a "tip" message during synthesis.

messageRequired
  • Type: str

The message.


annotate_generated
def annotate_generated(
  _glob: str
) -> None

Consider a set of files as "generated".

This method is implemented by derived classes and used for example, to add git attributes to tell GitHub that certain files are generated.

_globRequired
  • Type: str

the glob pattern to match (could be a file path).


post_synthesize
def post_synthesize() -> None

Called after all components are synthesized.

Order is not guaranteed.

pre_synthesize
def pre_synthesize() -> None

Called before all components are synthesized.

remove_task
def remove_task(
  name: str
) -> Task

Removes a task from a project.

nameRequired
  • Type: str

The name of the task to remove.


run_task_command
def run_task_command(
  task: Task
) -> str

Returns the shell command to execute in order to run a task.

By default, this is npx projen@<version> <task>

taskRequired
  • Type: projen.Task

The task for which the command is required.


synth
def synth() -> None

Synthesize all project files into outdir.

  1. Call "this.preSynthesize()"
  2. Delete all generated files
  3. Synthesize all subprojects
  4. Synthesize all components of this project
  5. Call "postSynthesize()" for all components of this project
  6. Call "this.postSynthesize()"
try_find_file
def try_find_file(
  file_path: str
) -> FileBase

Finds a file at the specified relative path within this project and all its subprojects.

file_pathRequired
  • Type: str

The file path.

If this path is relative, it will be resolved from the root of this project.


~~try_find_json_file~~
def try_find_json_file(
  file_path: str
) -> JsonFile

Finds a json file by name.

file_pathRequired
  • Type: str

The file path.


try_find_object_file
def try_find_object_file(
  file_path: str
) -> ObjectFile

Finds an object file (like JsonFile, YamlFile, etc.) by name.

file_pathRequired
  • Type: str

The file path.


try_remove_file
def try_remove_file(
  file_path: str
) -> FileBase

Finds a file at the specified relative path within this project and removes it.

file_pathRequired
  • Type: str

The file path.

If this path is relative, it will be resolved from the root of this project.


add_smithy_deps
def add_smithy_deps(
  deps: SmithyBaseProject
) -> None

Add a dependency on other smithy projects.

depsRequired

smithy_project_definition
def smithy_project_definition() -> SmithyProjectDefinition

Returns the smithy project definition.

Static Functions

Name Description
is_construct Checks if x is a construct.
is_project Test whether the given construct is a project.
of Find the closest ancestor project for given construct.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyBaseProject.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


is_project
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyBaseProject.is_project(
  x: typing.Any
)

Test whether the given construct is a project.

xRequired
  • Type: typing.Any

of
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyBaseProject.of(
  construct: IConstruct
)

Find the closest ancestor project for given construct.

When given a project, this it the project itself.

constructRequired
  • Type: constructs.IConstruct

Properties

Name Type Description
node constructs.Node The tree node.
build_task projen.Task No description.
commit_generated bool Whether to commit the managed files by default.
compile_task projen.Task No description.
components typing.List[projen.Component] Returns all the components within this project.
deps projen.Dependencies Project dependencies.
ejected bool Whether or not the project is being ejected.
files typing.List[projen.FileBase] All files in this project.
gitattributes projen.GitAttributesFile The .gitattributes file for this repository.
gitignore projen.IgnoreFile .gitignore.
logger projen.Logger Logging utilities.
name str Project name.
outdir str Absolute output directory of this project.
package_task projen.Task No description.
post_compile_task projen.Task No description.
pre_compile_task projen.Task No description.
project_build projen.ProjectBuild Manages the build process of the project.
projen_command str The command to use in order to run the projen CLI.
root projen.Project The root project.
subprojects typing.List[projen.Project] Returns all the subprojects within this project.
tasks projen.Tasks Project tasks.
test_task projen.Task No description.
default_task projen.Task This is the "default" task, the one that executes "projen".
init_project projen.InitProject The options used when this project is bootstrapped via projen new.
parent projen.Project A parent project.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


build_taskRequired
build_task: Task
  • Type: projen.Task

commit_generatedRequired
commit_generated: bool
  • Type: bool

Whether to commit the managed files by default.


compile_taskRequired
compile_task: Task
  • Type: projen.Task

componentsRequired
components: typing.List[Component]
  • Type: typing.List[projen.Component]

Returns all the components within this project.


depsRequired
deps: Dependencies
  • Type: projen.Dependencies

Project dependencies.


ejectedRequired
ejected: bool
  • Type: bool

Whether or not the project is being ejected.


filesRequired
files: typing.List[FileBase]
  • Type: typing.List[projen.FileBase]

All files in this project.


gitattributesRequired
gitattributes: GitAttributesFile
  • Type: projen.GitAttributesFile

The .gitattributes file for this repository.


gitignoreRequired
gitignore: IgnoreFile
  • Type: projen.IgnoreFile

.gitignore.


loggerRequired
logger: Logger
  • Type: projen.Logger

Logging utilities.


nameRequired
name: str
  • Type: str

Project name.


outdirRequired
outdir: str
  • Type: str

Absolute output directory of this project.


package_taskRequired
package_task: Task
  • Type: projen.Task

post_compile_taskRequired
post_compile_task: Task
  • Type: projen.Task

pre_compile_taskRequired
pre_compile_task: Task
  • Type: projen.Task

project_buildRequired
project_build: ProjectBuild
  • Type: projen.ProjectBuild

Manages the build process of the project.


projen_commandRequired
projen_command: str
  • Type: str

The command to use in order to run the projen CLI.


rootRequired
root: Project
  • Type: projen.Project

The root project.


subprojectsRequired
subprojects: typing.List[Project]
  • Type: typing.List[projen.Project]

Returns all the subprojects within this project.


tasksRequired
tasks: Tasks
  • Type: projen.Tasks

Project tasks.


test_taskRequired
test_task: Task
  • Type: projen.Task

default_taskOptional
default_task: Task
  • Type: projen.Task

This is the "default" task, the one that executes "projen".

Undefined if the project is being ejected.


init_projectOptional
init_project: InitProject
  • Type: projen.InitProject

The options used when this project is bootstrapped via projen new.

It includes the original set of options passed to the CLI and also the JSII FQN of the project type.


parentOptional
parent: Project
  • Type: projen.Project

A parent project.

If undefined, this is the root project.


Constants

Name Type Description
DEFAULT_TASK str The name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
DEFAULT_TASK: str
  • Type: str

The name of the default task (the task executed when projen is run without arguments).

Normally this task should synthesize the project files.


SmithyModelProject

Smithy model project for a REST API.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyModelProject(
  name: str,
  commit_generated: bool = None,
  git_ignore_options: IgnoreFileOptions = None,
  git_options: GitOptions = None,
  logging: LoggerOptions = None,
  outdir: str = None,
  parent: Project = None,
  projen_command: str = None,
  projenrc_json: bool = None,
  projenrc_json_options: ProjenrcJsonOptions = None,
  renovatebot: bool = None,
  renovatebot_options: RenovatebotOptions = None,
  smithy_options: SmithyModelOptions,
  handler_languages: typing.List[Language] = None,
  parsed_spec_file: str
)
Name Type Description
name str This is the name of your project.
commit_generated bool Whether to commit the managed files by default.
git_ignore_options projen.IgnoreFileOptions Configuration options for .gitignore file.
git_options projen.GitOptions Configuration options for git.
logging projen.LoggerOptions Configure logging options such as verbosity.
outdir str The root directory of the project.
parent projen.Project The parent project, if this project is part of a bigger project.
projen_command str The shell command to use in order to run the projen CLI.
projenrc_json bool Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.
projenrc_json_options projen.ProjenrcJsonOptions Options for .projenrc.json.
renovatebot bool Use renovatebot to handle dependency upgrades.
renovatebot_options projen.RenovatebotOptions Options for renovatebot.
smithy_options SmithyModelOptions Smithy engine options.
handler_languages typing.List[Language] The languages users have specified for handler projects (if any).
parsed_spec_file str Path of the parsed/bundled OpenAPI specification (relative to the project root).

nameRequired
  • Type: str
  • Default: $BASEDIR

This is the name of your project.


commit_generatedOptional
  • Type: bool
  • Default: true

Whether to commit the managed files by default.


git_ignore_optionsOptional
  • Type: projen.IgnoreFileOptions

Configuration options for .gitignore file.


git_optionsOptional
  • Type: projen.GitOptions

Configuration options for git.


loggingOptional
  • Type: projen.LoggerOptions
  • Default: {}

Configure logging options such as verbosity.


outdirOptional
  • Type: str
  • Default: "."

The root directory of the project.

Relative to this directory, all files are synthesized.

If this project has a parent, this directory is relative to the parent directory and it cannot be the same as the parent or any of it's other subprojects.


parentOptional
  • Type: projen.Project

The parent project, if this project is part of a bigger project.


projen_commandOptional
  • Type: str
  • Default: "npx projen"

The shell command to use in order to run the projen CLI.

Can be used to customize in special environments.


projenrc_jsonOptional
  • Type: bool
  • Default: false

Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.


projenrc_json_optionsOptional
  • Type: projen.ProjenrcJsonOptions
  • Default: default options

Options for .projenrc.json.


renovatebotOptional
  • Type: bool
  • Default: false

Use renovatebot to handle dependency upgrades.


renovatebot_optionsOptional
  • Type: projen.RenovatebotOptions
  • Default: default options

Options for renovatebot.


smithy_optionsRequired

Smithy engine options.


handler_languagesOptional

The languages users have specified for handler projects (if any).


parsed_spec_fileRequired
  • Type: str

Path of the parsed/bundled OpenAPI specification (relative to the project root).


Methods

Name Description
to_string Returns a string representation of this construct.
add_exclude_from_cleanup Exclude the matching files from pre-synth cleanup.
add_git_ignore Adds a .gitignore pattern.
add_package_ignore Exclude these files from the bundled package.
add_task Adds a new task to this project.
add_tip Prints a "tip" message during synthesis.
annotate_generated Consider a set of files as "generated".
post_synthesize Called after all components are synthesized.
pre_synthesize Called before all components are synthesized.
remove_task Removes a task from a project.
run_task_command Returns the shell command to execute in order to run a task.
synth Synthesize all project files into outdir.
try_find_file Finds a file at the specified relative path within this project and all its subprojects.
try_find_json_file Finds a json file by name.
try_find_object_file Finds an object file (like JsonFile, YamlFile, etc.) by name.
try_remove_file Finds a file at the specified relative path within this project and removes it.
add_smithy_deps Add a dependency on other smithy projects.
smithy_project_definition Returns the smithy project definition.

to_string
def to_string() -> str

Returns a string representation of this construct.

add_exclude_from_cleanup
def add_exclude_from_cleanup(
  globs: str
) -> None

Exclude the matching files from pre-synth cleanup.

Can be used when, for example, some source files include the projen marker and we don't want them to be erased during synth.

globsRequired
  • Type: str

The glob patterns to match.


add_git_ignore
def add_git_ignore(
  pattern: str
) -> None

Adds a .gitignore pattern.

patternRequired
  • Type: str

The glob pattern to ignore.


add_package_ignore
def add_package_ignore(
  _pattern: str
) -> None

Exclude these files from the bundled package.

Implemented by project types based on the packaging mechanism. For example, NodeProject delegates this to .npmignore.

_patternRequired
  • Type: str

The glob pattern to exclude.


add_task
def add_task(
  name: str,
  condition: str = None,
  cwd: str = None,
  description: str = None,
  env: typing.Mapping[str] = None,
  required_env: typing.List[str] = None,
  args: typing.List[str] = None,
  exec: str = None,
  receive_args: bool = None,
  steps: typing.List[TaskStep] = None
) -> Task

Adds a new task to this project.

This will fail if the project already has a task with this name.

nameRequired
  • Type: str

The task name to add.


conditionOptional
  • Type: str

A shell command which determines if the this task should be executed.

If the program exits with a zero exit code, steps will be executed. A non-zero code means that task will be skipped.


cwdOptional
  • Type: str
  • Default: process.cwd()

The working directory for all steps in this task (unless overridden by the step).


descriptionOptional
  • Type: str
  • Default: the task name

The description of this build command.


envOptional
  • Type: typing.Mapping[str]
  • Default: {}

Defines environment variables for the execution of this task.

Values in this map will be evaluated in a shell, so you can do stuff like $(echo "foo").


required_envOptional
  • Type: typing.List[str]

A set of environment variables that must be defined in order to execute this task.

Task execution will fail if one of these is not defined.


argsOptional
  • Type: typing.List[str]
  • Default: no arguments are passed to the step

Should the provided exec shell command receive fixed args.

{@link TaskStepOptions.args }


execOptional
  • Type: str
  • Default: add steps using task.exec(command) or task.spawn(subtask)

Shell command to execute as the first command of the task.


receive_argsOptional
  • Type: bool
  • Default: false

Should the provided exec shell command receive args passed to the task.

{@link TaskStepOptions.receiveArgs }


stepsOptional
  • Type: typing.List[projen.TaskStep]

List of task steps to run.


~~add_tip~~
def add_tip(
  message: str
) -> None

Prints a "tip" message during synthesis.

messageRequired
  • Type: str

The message.


annotate_generated
def annotate_generated(
  _glob: str
) -> None

Consider a set of files as "generated".

This method is implemented by derived classes and used for example, to add git attributes to tell GitHub that certain files are generated.

_globRequired
  • Type: str

the glob pattern to match (could be a file path).


post_synthesize
def post_synthesize() -> None

Called after all components are synthesized.

Order is not guaranteed.

pre_synthesize
def pre_synthesize() -> None

Called before all components are synthesized.

remove_task
def remove_task(
  name: str
) -> Task

Removes a task from a project.

nameRequired
  • Type: str

The name of the task to remove.


run_task_command
def run_task_command(
  task: Task
) -> str

Returns the shell command to execute in order to run a task.

By default, this is npx projen@<version> <task>

taskRequired
  • Type: projen.Task

The task for which the command is required.


synth
def synth() -> None

Synthesize all project files into outdir.

  1. Call "this.preSynthesize()"
  2. Delete all generated files
  3. Synthesize all subprojects
  4. Synthesize all components of this project
  5. Call "postSynthesize()" for all components of this project
  6. Call "this.postSynthesize()"
try_find_file
def try_find_file(
  file_path: str
) -> FileBase

Finds a file at the specified relative path within this project and all its subprojects.

file_pathRequired
  • Type: str

The file path.

If this path is relative, it will be resolved from the root of this project.


~~try_find_json_file~~
def try_find_json_file(
  file_path: str
) -> JsonFile

Finds a json file by name.

file_pathRequired
  • Type: str

The file path.


try_find_object_file
def try_find_object_file(
  file_path: str
) -> ObjectFile

Finds an object file (like JsonFile, YamlFile, etc.) by name.

file_pathRequired
  • Type: str

The file path.


try_remove_file
def try_remove_file(
  file_path: str
) -> FileBase

Finds a file at the specified relative path within this project and removes it.

file_pathRequired
  • Type: str

The file path.

If this path is relative, it will be resolved from the root of this project.


add_smithy_deps
def add_smithy_deps(
  deps: SmithyBaseProject
) -> None

Add a dependency on other smithy projects.

depsRequired

smithy_project_definition
def smithy_project_definition() -> SmithyProjectDefinition

Returns the smithy project definition.

Static Functions

Name Description
is_construct Checks if x is a construct.
is_project Test whether the given construct is a project.
of Find the closest ancestor project for given construct.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyModelProject.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


is_project
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyModelProject.is_project(
  x: typing.Any
)

Test whether the given construct is a project.

xRequired
  • Type: typing.Any

of
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyModelProject.of(
  construct: IConstruct
)

Find the closest ancestor project for given construct.

When given a project, this it the project itself.

constructRequired
  • Type: constructs.IConstruct

Properties

Name Type Description
node constructs.Node The tree node.
build_task projen.Task No description.
commit_generated bool Whether to commit the managed files by default.
compile_task projen.Task No description.
components typing.List[projen.Component] Returns all the components within this project.
deps projen.Dependencies Project dependencies.
ejected bool Whether or not the project is being ejected.
files typing.List[projen.FileBase] All files in this project.
gitattributes projen.GitAttributesFile The .gitattributes file for this repository.
gitignore projen.IgnoreFile .gitignore.
logger projen.Logger Logging utilities.
name str Project name.
outdir str Absolute output directory of this project.
package_task projen.Task No description.
post_compile_task projen.Task No description.
pre_compile_task projen.Task No description.
project_build projen.ProjectBuild Manages the build process of the project.
projen_command str The command to use in order to run the projen CLI.
root projen.Project The root project.
subprojects typing.List[projen.Project] Returns all the subprojects within this project.
tasks projen.Tasks Project tasks.
test_task projen.Task No description.
default_task projen.Task This is the "default" task, the one that executes "projen".
init_project projen.InitProject The options used when this project is bootstrapped via projen new.
parent projen.Project A parent project.
api_name str Name of the API.
definition SmithyServiceProjectDefinition Smithy model and build settings.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


build_taskRequired
build_task: Task
  • Type: projen.Task

commit_generatedRequired
commit_generated: bool
  • Type: bool

Whether to commit the managed files by default.


compile_taskRequired
compile_task: Task
  • Type: projen.Task

componentsRequired
components: typing.List[Component]
  • Type: typing.List[projen.Component]

Returns all the components within this project.


depsRequired
deps: Dependencies
  • Type: projen.Dependencies

Project dependencies.


ejectedRequired
ejected: bool
  • Type: bool

Whether or not the project is being ejected.


filesRequired
files: typing.List[FileBase]
  • Type: typing.List[projen.FileBase]

All files in this project.


gitattributesRequired
gitattributes: GitAttributesFile
  • Type: projen.GitAttributesFile

The .gitattributes file for this repository.


gitignoreRequired
gitignore: IgnoreFile
  • Type: projen.IgnoreFile

.gitignore.


loggerRequired
logger: Logger
  • Type: projen.Logger

Logging utilities.


nameRequired
name: str
  • Type: str

Project name.


outdirRequired
outdir: str
  • Type: str

Absolute output directory of this project.


package_taskRequired
package_task: Task
  • Type: projen.Task

post_compile_taskRequired
post_compile_task: Task
  • Type: projen.Task

pre_compile_taskRequired
pre_compile_task: Task
  • Type: projen.Task

project_buildRequired
project_build: ProjectBuild
  • Type: projen.ProjectBuild

Manages the build process of the project.


projen_commandRequired
projen_command: str
  • Type: str

The command to use in order to run the projen CLI.


rootRequired
root: Project
  • Type: projen.Project

The root project.


subprojectsRequired
subprojects: typing.List[Project]
  • Type: typing.List[projen.Project]

Returns all the subprojects within this project.


tasksRequired
tasks: Tasks
  • Type: projen.Tasks

Project tasks.


test_taskRequired
test_task: Task
  • Type: projen.Task

default_taskOptional
default_task: Task
  • Type: projen.Task

This is the "default" task, the one that executes "projen".

Undefined if the project is being ejected.


init_projectOptional
init_project: InitProject
  • Type: projen.InitProject

The options used when this project is bootstrapped via projen new.

It includes the original set of options passed to the CLI and also the JSII FQN of the project type.


parentOptional
parent: Project
  • Type: projen.Project

A parent project.

If undefined, this is the root project.


api_nameRequired
api_name: str
  • Type: str

Name of the API.


definitionRequired
definition: SmithyServiceProjectDefinition

Smithy model and build settings.


Constants

Name Type Description
DEFAULT_TASK str The name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
DEFAULT_TASK: str
  • Type: str

The name of the default task (the task executed when projen is run without arguments).

Normally this task should synthesize the project files.


SmithyProjectDefinition

Definition for a Smithy project.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyProjectDefinition(
  project: Project,
  ignore_gradle_wrapper: bool = None,
  ignore_smithy_build_output: bool = None,
  smithy_build_options: SmithyBuildOptions = None
)
Name Type Description
project projen.Project No description.
ignore_gradle_wrapper bool Set to false if you would like to check in your gradle wrapper.
ignore_smithy_build_output bool Set to false if you would like to check in your smithy build output or have more fine-grained control over what is checked in, eg if you add other projections to the smithy-build.json file.
smithy_build_options SmithyBuildOptions Smithy build options.

projectRequired
  • Type: projen.Project

ignore_gradle_wrapperOptional
  • Type: bool
  • Default: true

Set to false if you would like to check in your gradle wrapper.

Do so if you would like to use a different version of gradle to the one provided by default


ignore_smithy_build_outputOptional
  • Type: bool
  • Default: true

Set to false if you would like to check in your smithy build output or have more fine-grained control over what is checked in, eg if you add other projections to the smithy-build.json file.


smithy_build_optionsOptional

Smithy build options.


Methods

Name Description
to_string Returns a string representation of this construct.
post_synthesize Called after synthesis.
pre_synthesize Called before synthesis.
synthesize Synthesizes files to the project output directory.
add_deps Add maven-style or local file dependencies to the smithy model project.
add_smithy_deps Add dependencies on other smithy models, such that their shapes can be imported in this project.
add_sources Add additional paths to model source files or directories.

to_string
def to_string() -> str

Returns a string representation of this construct.

post_synthesize
def post_synthesize() -> None

Called after synthesis.

Order is not guaranteed.

pre_synthesize
def pre_synthesize() -> None

Called before synthesis.

synthesize
def synthesize() -> None

Synthesizes files to the project output directory.

add_deps
def add_deps(
  deps: str
) -> None

Add maven-style or local file dependencies to the smithy model project.

depsRequired
  • Type: str

dependencies to add, eg "software.amazon.smithy:smithy-validation-model:1.27.2" or "file://../some/path/build/lib/my-shapes.jar.


add_smithy_deps
def add_smithy_deps(
  deps: SmithyProjectDefinition
) -> None

Add dependencies on other smithy models, such that their shapes can be imported in this project.

depsRequired

smithy definitions to depend on.


add_sources
def add_sources(
  sources: str
) -> None

Add additional paths to model source files or directories.

Paths should be relative to the project outdir. Any absolute paths will be resolved as relative paths.

sourcesRequired
  • Type: str

Static Functions

Name Description
is_construct Checks if x is a construct.
is_component Test whether the given construct is a component.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyProjectDefinition.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


is_component
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyProjectDefinition.is_component(
  x: typing.Any
)

Test whether the given construct is a component.

xRequired
  • Type: typing.Any

Properties

Name Type Description
node constructs.Node The tree node.
project projen.Project No description.
gradle_project_name str Name of the gradle project.
model_dir str Directory of model source code.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


projectRequired
project: Project
  • Type: projen.Project

gradle_project_nameRequired
gradle_project_name: str
  • Type: str

Name of the gradle project.


model_dirRequired
model_dir: str
  • Type: str

Directory of model source code.


SmithyServiceProjectDefinition

Creates a project which defines a Smithy service, and transforms the Smithy model to OpenAPI.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyServiceProjectDefinition(
  project: Project,
  smithy_options: SmithyModelOptions,
  handler_languages: typing.List[Language] = None
)
Name Type Description
project projen.Project No description.
smithy_options SmithyModelOptions Smithy engine options.
handler_languages typing.List[Language] The languages users have specified for handler projects (if any).

projectRequired
  • Type: projen.Project

smithy_optionsRequired

Smithy engine options.


handler_languagesOptional

The languages users have specified for handler projects (if any).


Methods

Name Description
to_string Returns a string representation of this construct.
post_synthesize Called after synthesis.
pre_synthesize Called before synthesis.
synthesize Synthesizes files to the project output directory.
add_deps Add maven-style or local file dependencies to the smithy model project.
add_smithy_deps Add dependencies on other smithy models, such that their shapes can be imported in this project.
add_sources Add additional paths to model source files or directories.

to_string
def to_string() -> str

Returns a string representation of this construct.

post_synthesize
def post_synthesize() -> None

Called after synthesis.

Order is not guaranteed.

pre_synthesize
def pre_synthesize() -> None

Called before synthesis.

synthesize
def synthesize() -> None

Synthesizes files to the project output directory.

add_deps
def add_deps(
  deps: str
) -> None

Add maven-style or local file dependencies to the smithy model project.

depsRequired
  • Type: str

dependencies to add, eg "software.amazon.smithy:smithy-validation-model:1.27.2" or "file://../some/path/build/lib/my-shapes.jar.


add_smithy_deps
def add_smithy_deps(
  deps: SmithyProjectDefinition
) -> None

Add dependencies on other smithy models, such that their shapes can be imported in this project.

depsRequired

smithy definitions to depend on.


add_sources
def add_sources(
  sources: str
) -> None

Add additional paths to model source files or directories.

Paths should be relative to the project outdir. Any absolute paths will be resolved as relative paths.

sourcesRequired
  • Type: str

Static Functions

Name Description
is_construct Checks if x is a construct.
is_component Test whether the given construct is a component.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyServiceProjectDefinition.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


is_component
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyServiceProjectDefinition.is_component(
  x: typing.Any
)

Test whether the given construct is a component.

xRequired
  • Type: typing.Any

Properties

Name Type Description
node constructs.Node The tree node.
project projen.Project No description.
gradle_project_name str Name of the gradle project.
model_dir str Directory of model source code.
generated_model_dir str Directory of generated model source code.
open_api_specification_path str Path to the generated OpenAPI specification, relative to the project outdir.
smithy_json_model_path str Path to the json Smithy model, relative to the project outdir.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


projectRequired
project: Project
  • Type: projen.Project

gradle_project_nameRequired
gradle_project_name: str
  • Type: str

Name of the gradle project.


model_dirRequired
model_dir: str
  • Type: str

Directory of model source code.


generated_model_dirRequired
generated_model_dir: str
  • Type: str

Directory of generated model source code.


open_api_specification_pathRequired
open_api_specification_path: str
  • Type: str

Path to the generated OpenAPI specification, relative to the project outdir.


smithy_json_model_pathRequired
smithy_json_model_path: str
  • Type: str

Path to the json Smithy model, relative to the project outdir.


SmithyShapeLibraryProject

A project for defining a library of Smithy shapes which can be consumed by other projects.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyShapeLibraryProject(
  name: str,
  commit_generated: bool = None,
  git_ignore_options: IgnoreFileOptions = None,
  git_options: GitOptions = None,
  logging: LoggerOptions = None,
  outdir: str = None,
  parent: Project = None,
  projen_command: str = None,
  projenrc_json: bool = None,
  projenrc_json_options: ProjenrcJsonOptions = None,
  renovatebot: bool = None,
  renovatebot_options: RenovatebotOptions = None,
  ignore_gradle_wrapper: bool = None,
  ignore_smithy_build_output: bool = None,
  smithy_build_options: SmithyBuildOptions = None
)
Name Type Description
name str This is the name of your project.
commit_generated bool Whether to commit the managed files by default.
git_ignore_options projen.IgnoreFileOptions Configuration options for .gitignore file.
git_options projen.GitOptions Configuration options for git.
logging projen.LoggerOptions Configure logging options such as verbosity.
outdir str The root directory of the project.
parent projen.Project The parent project, if this project is part of a bigger project.
projen_command str The shell command to use in order to run the projen CLI.
projenrc_json bool Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.
projenrc_json_options projen.ProjenrcJsonOptions Options for .projenrc.json.
renovatebot bool Use renovatebot to handle dependency upgrades.
renovatebot_options projen.RenovatebotOptions Options for renovatebot.
ignore_gradle_wrapper bool Set to false if you would like to check in your gradle wrapper.
ignore_smithy_build_output bool Set to false if you would like to check in your smithy build output or have more fine-grained control over what is checked in, eg if you add other projections to the smithy-build.json file.
smithy_build_options SmithyBuildOptions Smithy build options.

nameRequired
  • Type: str
  • Default: $BASEDIR

This is the name of your project.


commit_generatedOptional
  • Type: bool
  • Default: true

Whether to commit the managed files by default.


git_ignore_optionsOptional
  • Type: projen.IgnoreFileOptions

Configuration options for .gitignore file.


git_optionsOptional
  • Type: projen.GitOptions

Configuration options for git.


loggingOptional
  • Type: projen.LoggerOptions
  • Default: {}

Configure logging options such as verbosity.


outdirOptional
  • Type: str
  • Default: "."

The root directory of the project.

Relative to this directory, all files are synthesized.

If this project has a parent, this directory is relative to the parent directory and it cannot be the same as the parent or any of it's other subprojects.


parentOptional
  • Type: projen.Project

The parent project, if this project is part of a bigger project.


projen_commandOptional
  • Type: str
  • Default: "npx projen"

The shell command to use in order to run the projen CLI.

Can be used to customize in special environments.


projenrc_jsonOptional
  • Type: bool
  • Default: false

Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.


projenrc_json_optionsOptional
  • Type: projen.ProjenrcJsonOptions
  • Default: default options

Options for .projenrc.json.


renovatebotOptional
  • Type: bool
  • Default: false

Use renovatebot to handle dependency upgrades.


renovatebot_optionsOptional
  • Type: projen.RenovatebotOptions
  • Default: default options

Options for renovatebot.


ignore_gradle_wrapperOptional
  • Type: bool
  • Default: true

Set to false if you would like to check in your gradle wrapper.

Do so if you would like to use a different version of gradle to the one provided by default


ignore_smithy_build_outputOptional
  • Type: bool
  • Default: true

Set to false if you would like to check in your smithy build output or have more fine-grained control over what is checked in, eg if you add other projections to the smithy-build.json file.


smithy_build_optionsOptional

Smithy build options.


Methods

Name Description
to_string Returns a string representation of this construct.
add_exclude_from_cleanup Exclude the matching files from pre-synth cleanup.
add_git_ignore Adds a .gitignore pattern.
add_package_ignore Exclude these files from the bundled package.
add_task Adds a new task to this project.
add_tip Prints a "tip" message during synthesis.
annotate_generated Consider a set of files as "generated".
post_synthesize Called after all components are synthesized.
pre_synthesize Called before all components are synthesized.
remove_task Removes a task from a project.
run_task_command Returns the shell command to execute in order to run a task.
synth Synthesize all project files into outdir.
try_find_file Finds a file at the specified relative path within this project and all its subprojects.
try_find_json_file Finds a json file by name.
try_find_object_file Finds an object file (like JsonFile, YamlFile, etc.) by name.
try_remove_file Finds a file at the specified relative path within this project and removes it.
add_smithy_deps Add a dependency on other smithy projects.
smithy_project_definition Returns the smithy project definition.

to_string
def to_string() -> str

Returns a string representation of this construct.

add_exclude_from_cleanup
def add_exclude_from_cleanup(
  globs: str
) -> None

Exclude the matching files from pre-synth cleanup.

Can be used when, for example, some source files include the projen marker and we don't want them to be erased during synth.

globsRequired
  • Type: str

The glob patterns to match.


add_git_ignore
def add_git_ignore(
  pattern: str
) -> None

Adds a .gitignore pattern.

patternRequired
  • Type: str

The glob pattern to ignore.


add_package_ignore
def add_package_ignore(
  _pattern: str
) -> None

Exclude these files from the bundled package.

Implemented by project types based on the packaging mechanism. For example, NodeProject delegates this to .npmignore.

_patternRequired
  • Type: str

The glob pattern to exclude.


add_task
def add_task(
  name: str,
  condition: str = None,
  cwd: str = None,
  description: str = None,
  env: typing.Mapping[str] = None,
  required_env: typing.List[str] = None,
  args: typing.List[str] = None,
  exec: str = None,
  receive_args: bool = None,
  steps: typing.List[TaskStep] = None
) -> Task

Adds a new task to this project.

This will fail if the project already has a task with this name.

nameRequired
  • Type: str

The task name to add.


conditionOptional
  • Type: str

A shell command which determines if the this task should be executed.

If the program exits with a zero exit code, steps will be executed. A non-zero code means that task will be skipped.


cwdOptional
  • Type: str
  • Default: process.cwd()

The working directory for all steps in this task (unless overridden by the step).


descriptionOptional
  • Type: str
  • Default: the task name

The description of this build command.


envOptional
  • Type: typing.Mapping[str]
  • Default: {}

Defines environment variables for the execution of this task.

Values in this map will be evaluated in a shell, so you can do stuff like $(echo "foo").


required_envOptional
  • Type: typing.List[str]

A set of environment variables that must be defined in order to execute this task.

Task execution will fail if one of these is not defined.


argsOptional
  • Type: typing.List[str]
  • Default: no arguments are passed to the step

Should the provided exec shell command receive fixed args.

{@link TaskStepOptions.args }


execOptional
  • Type: str
  • Default: add steps using task.exec(command) or task.spawn(subtask)

Shell command to execute as the first command of the task.


receive_argsOptional
  • Type: bool
  • Default: false

Should the provided exec shell command receive args passed to the task.

{@link TaskStepOptions.receiveArgs }


stepsOptional
  • Type: typing.List[projen.TaskStep]

List of task steps to run.


~~add_tip~~
def add_tip(
  message: str
) -> None

Prints a "tip" message during synthesis.

messageRequired
  • Type: str

The message.


annotate_generated
def annotate_generated(
  _glob: str
) -> None

Consider a set of files as "generated".

This method is implemented by derived classes and used for example, to add git attributes to tell GitHub that certain files are generated.

_globRequired
  • Type: str

the glob pattern to match (could be a file path).


post_synthesize
def post_synthesize() -> None

Called after all components are synthesized.

Order is not guaranteed.

pre_synthesize
def pre_synthesize() -> None

Called before all components are synthesized.

remove_task
def remove_task(
  name: str
) -> Task

Removes a task from a project.

nameRequired
  • Type: str

The name of the task to remove.


run_task_command
def run_task_command(
  task: Task
) -> str

Returns the shell command to execute in order to run a task.

By default, this is npx projen@<version> <task>

taskRequired
  • Type: projen.Task

The task for which the command is required.


synth
def synth() -> None

Synthesize all project files into outdir.

  1. Call "this.preSynthesize()"
  2. Delete all generated files
  3. Synthesize all subprojects
  4. Synthesize all components of this project
  5. Call "postSynthesize()" for all components of this project
  6. Call "this.postSynthesize()"
try_find_file
def try_find_file(
  file_path: str
) -> FileBase

Finds a file at the specified relative path within this project and all its subprojects.

file_pathRequired
  • Type: str

The file path.

If this path is relative, it will be resolved from the root of this project.


~~try_find_json_file~~
def try_find_json_file(
  file_path: str
) -> JsonFile

Finds a json file by name.

file_pathRequired
  • Type: str

The file path.


try_find_object_file
def try_find_object_file(
  file_path: str
) -> ObjectFile

Finds an object file (like JsonFile, YamlFile, etc.) by name.

file_pathRequired
  • Type: str

The file path.


try_remove_file
def try_remove_file(
  file_path: str
) -> FileBase

Finds a file at the specified relative path within this project and removes it.

file_pathRequired
  • Type: str

The file path.

If this path is relative, it will be resolved from the root of this project.


add_smithy_deps
def add_smithy_deps(
  deps: SmithyBaseProject
) -> None

Add a dependency on other smithy projects.

depsRequired

smithy_project_definition
def smithy_project_definition() -> SmithyProjectDefinition

Returns the smithy project definition.

Static Functions

Name Description
is_construct Checks if x is a construct.
is_project Test whether the given construct is a project.
of Find the closest ancestor project for given construct.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyShapeLibraryProject.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


is_project
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyShapeLibraryProject.is_project(
  x: typing.Any
)

Test whether the given construct is a project.

xRequired
  • Type: typing.Any

of
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SmithyShapeLibraryProject.of(
  construct: IConstruct
)

Find the closest ancestor project for given construct.

When given a project, this it the project itself.

constructRequired
  • Type: constructs.IConstruct

Properties

Name Type Description
node constructs.Node The tree node.
build_task projen.Task No description.
commit_generated bool Whether to commit the managed files by default.
compile_task projen.Task No description.
components typing.List[projen.Component] Returns all the components within this project.
deps projen.Dependencies Project dependencies.
ejected bool Whether or not the project is being ejected.
files typing.List[projen.FileBase] All files in this project.
gitattributes projen.GitAttributesFile The .gitattributes file for this repository.
gitignore projen.IgnoreFile .gitignore.
logger projen.Logger Logging utilities.
name str Project name.
outdir str Absolute output directory of this project.
package_task projen.Task No description.
post_compile_task projen.Task No description.
pre_compile_task projen.Task No description.
project_build projen.ProjectBuild Manages the build process of the project.
projen_command str The command to use in order to run the projen CLI.
root projen.Project The root project.
subprojects typing.List[projen.Project] Returns all the subprojects within this project.
tasks projen.Tasks Project tasks.
test_task projen.Task No description.
default_task projen.Task This is the "default" task, the one that executes "projen".
init_project projen.InitProject The options used when this project is bootstrapped via projen new.
parent projen.Project A parent project.
definition SmithyProjectDefinition Smithy model and build settings.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


build_taskRequired
build_task: Task
  • Type: projen.Task

commit_generatedRequired
commit_generated: bool
  • Type: bool

Whether to commit the managed files by default.


compile_taskRequired
compile_task: Task
  • Type: projen.Task

componentsRequired
components: typing.List[Component]
  • Type: typing.List[projen.Component]

Returns all the components within this project.


depsRequired
deps: Dependencies
  • Type: projen.Dependencies

Project dependencies.


ejectedRequired
ejected: bool
  • Type: bool

Whether or not the project is being ejected.


filesRequired
files: typing.List[FileBase]
  • Type: typing.List[projen.FileBase]

All files in this project.


gitattributesRequired
gitattributes: GitAttributesFile
  • Type: projen.GitAttributesFile

The .gitattributes file for this repository.


gitignoreRequired
gitignore: IgnoreFile
  • Type: projen.IgnoreFile

.gitignore.


loggerRequired
logger: Logger
  • Type: projen.Logger

Logging utilities.


nameRequired
name: str
  • Type: str

Project name.


outdirRequired
outdir: str
  • Type: str

Absolute output directory of this project.


package_taskRequired
package_task: Task
  • Type: projen.Task

post_compile_taskRequired
post_compile_task: Task
  • Type: projen.Task

pre_compile_taskRequired
pre_compile_task: Task
  • Type: projen.Task

project_buildRequired
project_build: ProjectBuild
  • Type: projen.ProjectBuild

Manages the build process of the project.


projen_commandRequired
projen_command: str
  • Type: str

The command to use in order to run the projen CLI.


rootRequired
root: Project
  • Type: projen.Project

The root project.


subprojectsRequired
subprojects: typing.List[Project]
  • Type: typing.List[projen.Project]

Returns all the subprojects within this project.


tasksRequired
tasks: Tasks
  • Type: projen.Tasks

Project tasks.


test_taskRequired
test_task: Task
  • Type: projen.Task

default_taskOptional
default_task: Task
  • Type: projen.Task

This is the "default" task, the one that executes "projen".

Undefined if the project is being ejected.


init_projectOptional
init_project: InitProject
  • Type: projen.InitProject

The options used when this project is bootstrapped via projen new.

It includes the original set of options passed to the CLI and also the JSII FQN of the project type.


parentOptional
parent: Project
  • Type: projen.Project

A parent project.

If undefined, this is the root project.


definitionRequired
definition: SmithyProjectDefinition

Smithy model and build settings.


Constants

Name Type Description
DEFAULT_TASK str The name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
DEFAULT_TASK: str
  • Type: str

The name of the default task (the task executed when projen is run without arguments).

Normally this task should synthesize the project files.


SnapStartFunction

A lambda function which enables SnapStart on published versions by default.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SnapStartFunction(
  scope: Construct,
  id: str,
  max_event_age: Duration = None,
  on_failure: IDestination = None,
  on_success: IDestination = None,
  retry_attempts: typing.Union[int, float] = None,
  adot_instrumentation: AdotInstrumentationConfig = None,
  allow_all_ipv6_outbound: bool = None,
  allow_all_outbound: bool = None,
  allow_public_subnet: bool = None,
  application_log_level: str = None,
  application_log_level_v2: ApplicationLogLevel = None,
  architecture: Architecture = None,
  code_signing_config: ICodeSigningConfig = None,
  current_version_options: VersionOptions = None,
  dead_letter_queue: IQueue = None,
  dead_letter_queue_enabled: bool = None,
  dead_letter_topic: ITopic = None,
  description: str = None,
  environment: typing.Mapping[str] = None,
  environment_encryption: IKey = None,
  ephemeral_storage_size: Size = None,
  events: typing.List[IEventSource] = None,
  filesystem: FileSystem = None,
  function_name: str = None,
  initial_policy: typing.List[PolicyStatement] = None,
  insights_version: LambdaInsightsVersion = None,
  ipv6_allowed_for_dual_stack: bool = None,
  layers: typing.List[ILayerVersion] = None,
  log_format: str = None,
  logging_format: LoggingFormat = None,
  log_group: ILogGroup = None,
  log_retention: RetentionDays = None,
  log_retention_retry_options: LogRetentionRetryOptions = None,
  log_retention_role: IRole = None,
  memory_size: typing.Union[int, float] = None,
  params_and_secrets: ParamsAndSecretsLayerVersion = None,
  profiling: bool = None,
  profiling_group: IProfilingGroup = None,
  recursive_loop: RecursiveLoop = None,
  reserved_concurrent_executions: typing.Union[int, float] = None,
  role: IRole = None,
  runtime_management_mode: RuntimeManagementMode = None,
  security_groups: typing.List[ISecurityGroup] = None,
  snap_start: SnapStartConf = None,
  system_log_level: str = None,
  system_log_level_v2: SystemLogLevel = None,
  timeout: Duration = None,
  tracing: Tracing = None,
  vpc: IVpc = None,
  vpc_subnets: SubnetSelection = None,
  code: Code,
  handler: str,
  runtime: Runtime,
  disable_snap_start: bool = None
)
Name Type Description
scope constructs.Construct No description.
id str No description.
max_event_age aws_cdk.Duration The maximum age of a request that Lambda sends to a function for processing.
on_failure aws_cdk.aws_lambda.IDestination The destination for failed invocations.
on_success aws_cdk.aws_lambda.IDestination The destination for successful invocations.
retry_attempts typing.Union[int, float] The maximum number of times to retry when the function returns an error.
adot_instrumentation aws_cdk.aws_lambda.AdotInstrumentationConfig Specify the configuration of AWS Distro for OpenTelemetry (ADOT) instrumentation.
allow_all_ipv6_outbound bool Whether to allow the Lambda to send all ipv6 network traffic.
allow_all_outbound bool Whether to allow the Lambda to send all network traffic (except ipv6).
allow_public_subnet bool Lambda Functions in a public subnet can NOT access the internet.
application_log_level str Sets the application log level for the function.
application_log_level_v2 aws_cdk.aws_lambda.ApplicationLogLevel Sets the application log level for the function.
architecture aws_cdk.aws_lambda.Architecture The system architectures compatible with this lambda function.
code_signing_config aws_cdk.aws_lambda.ICodeSigningConfig Code signing config associated with this function.
current_version_options aws_cdk.aws_lambda.VersionOptions Options for the lambda.Version resource automatically created by the fn.currentVersion method.
dead_letter_queue aws_cdk.aws_sqs.IQueue The SQS queue to use if DLQ is enabled.
dead_letter_queue_enabled bool Enabled DLQ.
dead_letter_topic aws_cdk.aws_sns.ITopic The SNS topic to use as a DLQ.
description str A description of the function.
environment typing.Mapping[str] Key-value pairs that Lambda caches and makes available for your Lambda functions.
environment_encryption aws_cdk.aws_kms.IKey The AWS KMS key that's used to encrypt your function's environment variables.
ephemeral_storage_size aws_cdk.Size The size of the function’s /tmp directory in MiB.
events typing.List[aws_cdk.aws_lambda.IEventSource] Event sources for this function.
filesystem aws_cdk.aws_lambda.FileSystem The filesystem configuration for the lambda function.
function_name str A name for the function.
initial_policy typing.List[aws_cdk.aws_iam.PolicyStatement] Initial policy statements to add to the created Lambda Role.
insights_version aws_cdk.aws_lambda.LambdaInsightsVersion Specify the version of CloudWatch Lambda insights to use for monitoring.
ipv6_allowed_for_dual_stack bool Allows outbound IPv6 traffic on VPC functions that are connected to dual-stack subnets.
layers typing.List[aws_cdk.aws_lambda.ILayerVersion] A list of layers to add to the function's execution environment.
log_format str Sets the logFormat for the function.
logging_format aws_cdk.aws_lambda.LoggingFormat Sets the loggingFormat for the function.
log_group aws_cdk.aws_logs.ILogGroup The log group the function sends logs to.
log_retention aws_cdk.aws_logs.RetentionDays The number of days log events are kept in CloudWatch Logs.
log_retention_retry_options aws_cdk.aws_lambda.LogRetentionRetryOptions When log retention is specified, a custom resource attempts to create the CloudWatch log group.
log_retention_role aws_cdk.aws_iam.IRole The IAM role for the Lambda function associated with the custom resource that sets the retention policy.
memory_size typing.Union[int, float] The amount of memory, in MB, that is allocated to your Lambda function.
params_and_secrets aws_cdk.aws_lambda.ParamsAndSecretsLayerVersion Specify the configuration of Parameters and Secrets Extension.
profiling bool Enable profiling.
profiling_group aws_cdk.aws_codeguruprofiler.IProfilingGroup Profiling Group.
recursive_loop aws_cdk.aws_lambda.RecursiveLoop Sets the Recursive Loop Protection for Lambda Function.
reserved_concurrent_executions typing.Union[int, float] The maximum of concurrent executions you want to reserve for the function.
role aws_cdk.aws_iam.IRole Lambda execution role.
runtime_management_mode aws_cdk.aws_lambda.RuntimeManagementMode Sets the runtime management configuration for a function's version.
security_groups typing.List[aws_cdk.aws_ec2.ISecurityGroup] The list of security groups to associate with the Lambda's network interfaces.
snap_start aws_cdk.aws_lambda.SnapStartConf Enable SnapStart for Lambda Function.
system_log_level str Sets the system log level for the function.
system_log_level_v2 aws_cdk.aws_lambda.SystemLogLevel Sets the system log level for the function.
timeout aws_cdk.Duration The function execution time (in seconds) after which Lambda terminates the function.
tracing aws_cdk.aws_lambda.Tracing Enable AWS X-Ray Tracing for Lambda Function.
vpc aws_cdk.aws_ec2.IVpc VPC network to place Lambda network interfaces.
vpc_subnets aws_cdk.aws_ec2.SubnetSelection Where to place the network interfaces within the VPC.
code aws_cdk.aws_lambda.Code The source code of your Lambda function.
handler str The name of the method within your code that Lambda calls to execute your function.
runtime aws_cdk.aws_lambda.Runtime The runtime environment for the Lambda function that you are uploading.
disable_snap_start bool When true, disable snap start.

scopeRequired
  • Type: constructs.Construct

idRequired
  • Type: str

max_event_ageOptional
  • Type: aws_cdk.Duration
  • Default: Duration.hours(6)

The maximum age of a request that Lambda sends to a function for processing.

Minimum: 60 seconds Maximum: 6 hours


on_failureOptional
  • Type: aws_cdk.aws_lambda.IDestination
  • Default: no destination

The destination for failed invocations.


on_successOptional
  • Type: aws_cdk.aws_lambda.IDestination
  • Default: no destination

The destination for successful invocations.


retry_attemptsOptional
  • Type: typing.Union[int, float]
  • Default: 2

The maximum number of times to retry when the function returns an error.

Minimum: 0 Maximum: 2


adot_instrumentationOptional
  • Type: aws_cdk.aws_lambda.AdotInstrumentationConfig
  • Default: No ADOT instrumentation

Specify the configuration of AWS Distro for OpenTelemetry (ADOT) instrumentation.

https://aws-otel.github.io/docs/getting-started/lambda


allow_all_ipv6_outboundOptional
  • Type: bool
  • Default: false

Whether to allow the Lambda to send all ipv6 network traffic.

If set to true, there will only be a single egress rule which allows all outbound ipv6 traffic. If set to false, you must individually add traffic rules to allow the Lambda to connect to network targets using ipv6.

Do not specify this property if the securityGroups or securityGroup property is set. Instead, configure allowAllIpv6Outbound directly on the security group.


allow_all_outboundOptional
  • Type: bool
  • Default: true

Whether to allow the Lambda to send all network traffic (except ipv6).

If set to false, you must individually add traffic rules to allow the Lambda to connect to network targets.

Do not specify this property if the securityGroups or securityGroup property is set. Instead, configure allowAllOutbound directly on the security group.


allow_public_subnetOptional
  • Type: bool
  • Default: false

Lambda Functions in a public subnet can NOT access the internet.

Use this property to acknowledge this limitation and still place the function in a public subnet.

https://stackoverflow.com/questions/52992085/why-cant-an-aws-lambda-function-inside-a-public-subnet-in-a-vpc-connect-to-the/52994841#52994841


~~application_log_level~~Optional
  • Deprecated: Use applicationLogLevelV2 as a property instead.

  • Type: str

  • Default: "INFO"

Sets the application log level for the function.


application_log_level_v2Optional
  • Type: aws_cdk.aws_lambda.ApplicationLogLevel
  • Default: ApplicationLogLevel.INFO

Sets the application log level for the function.


architectureOptional
  • Type: aws_cdk.aws_lambda.Architecture
  • Default: Architecture.X86_64

The system architectures compatible with this lambda function.


code_signing_configOptional
  • Type: aws_cdk.aws_lambda.ICodeSigningConfig
  • Default: Not Sign the Code

Code signing config associated with this function.


current_version_optionsOptional
  • Type: aws_cdk.aws_lambda.VersionOptions
  • Default: default options as described in VersionOptions

Options for the lambda.Version resource automatically created by the fn.currentVersion method.


dead_letter_queueOptional
  • Type: aws_cdk.aws_sqs.IQueue
  • Default: SQS queue with 14 day retention period if deadLetterQueueEnabled is true

The SQS queue to use if DLQ is enabled.

If SNS topic is desired, specify deadLetterTopic property instead.


dead_letter_queue_enabledOptional
  • Type: bool
  • Default: false unless deadLetterQueue is set, which implies DLQ is enabled.

Enabled DLQ.

If deadLetterQueue is undefined, an SQS queue with default options will be defined for your Function.


dead_letter_topicOptional
  • Type: aws_cdk.aws_sns.ITopic
  • Default: no SNS topic

The SNS topic to use as a DLQ.

Note that if deadLetterQueueEnabled is set to true, an SQS queue will be created rather than an SNS topic. Using an SNS topic as a DLQ requires this property to be set explicitly.


descriptionOptional
  • Type: str
  • Default: No description.

A description of the function.


environmentOptional
  • Type: typing.Mapping[str]
  • Default: No environment variables.

Key-value pairs that Lambda caches and makes available for your Lambda functions.

Use environment variables to apply configuration changes, such as test and production environment configurations, without changing your Lambda function source code.


environment_encryptionOptional
  • Type: aws_cdk.aws_kms.IKey
  • Default: AWS Lambda creates and uses an AWS managed customer master key (CMK).

The AWS KMS key that's used to encrypt your function's environment variables.


ephemeral_storage_sizeOptional
  • Type: aws_cdk.Size
  • Default: 512 MiB

The size of the function’s /tmp directory in MiB.


eventsOptional
  • Type: typing.List[aws_cdk.aws_lambda.IEventSource]
  • Default: No event sources.

Event sources for this function.

You can also add event sources using addEventSource.


filesystemOptional
  • Type: aws_cdk.aws_lambda.FileSystem
  • Default: will not mount any filesystem

The filesystem configuration for the lambda function.


function_nameOptional
  • Type: str
  • Default: AWS CloudFormation generates a unique physical ID and uses that ID for the function's name. For more information, see Name Type.

A name for the function.


initial_policyOptional
  • Type: typing.List[aws_cdk.aws_iam.PolicyStatement]
  • Default: No policy statements are added to the created Lambda role.

Initial policy statements to add to the created Lambda Role.

You can call addToRolePolicy to the created lambda to add statements post creation.


insights_versionOptional
  • Type: aws_cdk.aws_lambda.LambdaInsightsVersion
  • Default: No Lambda Insights

Specify the version of CloudWatch Lambda insights to use for monitoring.

https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Lambda-Insights-Getting-Started-docker.html


ipv6_allowed_for_dual_stackOptional
  • Type: bool
  • Default: false

Allows outbound IPv6 traffic on VPC functions that are connected to dual-stack subnets.

Only used if 'vpc' is supplied.


layersOptional
  • Type: typing.List[aws_cdk.aws_lambda.ILayerVersion]
  • Default: No layers.

A list of layers to add to the function's execution environment.

You can configure your Lambda function to pull in additional code during initialization in the form of layers. Layers are packages of libraries or other dependencies that can be used by multiple functions.


~~log_format~~Optional
  • Deprecated: Use loggingFormat as a property instead.

  • Type: str

  • Default: "Text"

Sets the logFormat for the function.


logging_formatOptional
  • Type: aws_cdk.aws_lambda.LoggingFormat
  • Default: LoggingFormat.TEXT

Sets the loggingFormat for the function.


log_groupOptional
  • Type: aws_cdk.aws_logs.ILogGroup
  • Default: /aws/lambda/${this.functionName} - default log group created by Lambda

The log group the function sends logs to.

By default, Lambda functions send logs to an automatically created default log group named /aws/lambda/\<function name>. However you cannot change the properties of this auto-created log group using the AWS CDK, e.g. you cannot set a different log retention.

Use the logGroup property to create a fully customizable LogGroup ahead of time, and instruct the Lambda function to send logs to it.

Providing a user-controlled log group was rolled out to commercial regions on 2023-11-16. If you are deploying to another type of region, please check regional availability first.


log_retentionOptional
  • Type: aws_cdk.aws_logs.RetentionDays
  • Default: logs.RetentionDays.INFINITE

The number of days log events are kept in CloudWatch Logs.

When updating this property, unsetting it doesn't remove the log retention policy. To remove the retention policy, set the value to INFINITE.

This is a legacy API and we strongly recommend you move away from it if you can. Instead create a fully customizable log group with logs.LogGroup and use the logGroup property to instruct the Lambda function to send logs to it. Migrating from logRetention to logGroup will cause the name of the log group to change. Users and code and referencing the name verbatim will have to adjust.

In AWS CDK code, you can access the log group name directly from the LogGroup construct:

import * as logs from 'aws-cdk-lib/aws-logs';

declare const myLogGroup: logs.LogGroup;
myLogGroup.logGroupName;


log_retention_retry_optionsOptional
  • Type: aws_cdk.aws_lambda.LogRetentionRetryOptions
  • Default: Default AWS SDK retry options.

When log retention is specified, a custom resource attempts to create the CloudWatch log group.

These options control the retry policy when interacting with CloudWatch APIs.

This is a legacy API and we strongly recommend you migrate to logGroup if you can. logGroup allows you to create a fully customizable log group and instruct the Lambda function to send logs to it.


log_retention_roleOptional
  • Type: aws_cdk.aws_iam.IRole
  • Default: A new role is created.

The IAM role for the Lambda function associated with the custom resource that sets the retention policy.

This is a legacy API and we strongly recommend you migrate to logGroup if you can. logGroup allows you to create a fully customizable log group and instruct the Lambda function to send logs to it.


memory_sizeOptional
  • Type: typing.Union[int, float]
  • Default: 128

The amount of memory, in MB, that is allocated to your Lambda function.

Lambda uses this value to proportionally allocate the amount of CPU power. For more information, see Resource Model in the AWS Lambda Developer Guide.


params_and_secretsOptional
  • Type: aws_cdk.aws_lambda.ParamsAndSecretsLayerVersion
  • Default: No Parameters and Secrets Extension

Specify the configuration of Parameters and Secrets Extension.

https://docs.aws.amazon.com/systems-manager/latest/userguide/ps-integration-lambda-extensions.html


profilingOptional
  • Type: bool
  • Default: No profiling.

Enable profiling.

https://docs.aws.amazon.com/codeguru/latest/profiler-ug/setting-up-lambda.html


profiling_groupOptional
  • Type: aws_cdk.aws_codeguruprofiler.IProfilingGroup
  • Default: A new profiling group will be created if profiling is set.

Profiling Group.

https://docs.aws.amazon.com/codeguru/latest/profiler-ug/setting-up-lambda.html


recursive_loopOptional
  • Type: aws_cdk.aws_lambda.RecursiveLoop
  • Default: RecursiveLoop.Terminate

Sets the Recursive Loop Protection for Lambda Function.

It lets Lambda detect and terminate unintended recusrive loops.


reserved_concurrent_executionsOptional
  • Type: typing.Union[int, float]
  • Default: No specific limit - account limit.

The maximum of concurrent executions you want to reserve for the function.

https://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html


roleOptional
  • Type: aws_cdk.aws_iam.IRole
  • Default: A unique role will be generated for this lambda function. Both supplied and generated roles can always be changed by calling addToRolePolicy.

Lambda execution role.

This is the role that will be assumed by the function upon execution. It controls the permissions that the function will have. The Role must be assumable by the 'lambda.amazonaws.com' service principal.

The default Role automatically has permissions granted for Lambda execution. If you provide a Role, you must add the relevant AWS managed policies yourself.

The relevant managed policies are "service-role/AWSLambdaBasicExecutionRole" and "service-role/AWSLambdaVPCAccessExecutionRole".


runtime_management_modeOptional
  • Type: aws_cdk.aws_lambda.RuntimeManagementMode
  • Default: Auto

Sets the runtime management configuration for a function's version.


security_groupsOptional
  • Type: typing.List[aws_cdk.aws_ec2.ISecurityGroup]
  • Default: If the function is placed within a VPC and a security group is not specified, either by this or securityGroup prop, a dedicated security group will be created for this function.

The list of security groups to associate with the Lambda's network interfaces.

Only used if 'vpc' is supplied.


snap_startOptional
  • Type: aws_cdk.aws_lambda.SnapStartConf
  • Default: No snapstart

Enable SnapStart for Lambda Function.

SnapStart is currently supported only for Java 11, 17 runtime


~~system_log_level~~Optional
  • Deprecated: Use systemLogLevelV2 as a property instead.

  • Type: str

  • Default: "INFO"

Sets the system log level for the function.


system_log_level_v2Optional
  • Type: aws_cdk.aws_lambda.SystemLogLevel
  • Default: SystemLogLevel.INFO

Sets the system log level for the function.


timeoutOptional
  • Type: aws_cdk.Duration
  • Default: Duration.seconds(3)

The function execution time (in seconds) after which Lambda terminates the function.

Because the execution time affects cost, set this value based on the function's expected execution time.


tracingOptional
  • Type: aws_cdk.aws_lambda.Tracing
  • Default: Tracing.Disabled

Enable AWS X-Ray Tracing for Lambda Function.


vpcOptional
  • Type: aws_cdk.aws_ec2.IVpc
  • Default: Function is not placed within a VPC.

VPC network to place Lambda network interfaces.

Specify this if the Lambda function needs to access resources in a VPC. This is required when vpcSubnets is specified.


vpc_subnetsOptional
  • Type: aws_cdk.aws_ec2.SubnetSelection
  • Default: the Vpc default strategy if not specified

Where to place the network interfaces within the VPC.

This requires vpc to be specified in order for interfaces to actually be placed in the subnets. If vpc is not specify, this will raise an error.

Note: Internet access for Lambda Functions requires a NAT Gateway, so picking public subnets is not allowed (unless allowPublicSubnet is set to true).


codeRequired
  • Type: aws_cdk.aws_lambda.Code

The source code of your Lambda function.

You can point to a file in an Amazon Simple Storage Service (Amazon S3) bucket or specify your source code as inline text.


handlerRequired
  • Type: str

The name of the method within your code that Lambda calls to execute your function.

The format includes the file name. It can also include namespaces and other qualifiers, depending on the runtime. For more information, see https://docs.aws.amazon.com/lambda/latest/dg/foundation-progmodel.html.

Use Handler.FROM_IMAGE when defining a function from a Docker image.

NOTE: If you specify your source code as inline text by specifying the ZipFile property within the Code property, specify index.function_name as the handler.


runtimeRequired
  • Type: aws_cdk.aws_lambda.Runtime

The runtime environment for the Lambda function that you are uploading.

For valid values, see the Runtime property in the AWS Lambda Developer Guide.

Use Runtime.FROM_IMAGE when defining a function from a Docker image.


disable_snap_startOptional
  • Type: bool
  • Default: false

When true, disable snap start.


Methods

Name Description
to_string Returns a string representation of this construct.
apply_removal_policy Apply the given removal policy to this resource.
add_event_source Adds an event source to this function.
add_event_source_mapping Adds an event source that maps to this AWS Lambda function.
add_function_url Adds a url to this lambda function.
add_permission Adds a permission to the Lambda resource policy.
add_to_role_policy Adds a statement to the IAM role assumed by the instance.
configure_async_invoke Configures options for asynchronous invocation.
consider_warning_on_invoke_function_permissions A warning will be added to functions under the following conditions: - permissions that include lambda:InvokeFunction are added to the unqualified function.
grant_invoke Grant the given identity permissions to invoke this Lambda.
grant_invoke_composite_principal Grant multiple principals the ability to invoke this Lambda via CompositePrincipal.
grant_invoke_latest_version Grant the given identity permissions to invoke the $LATEST version or unqualified version of this Lambda.
grant_invoke_url Grant the given identity permissions to invoke this Lambda Function URL.
grant_invoke_version Grant the given identity permissions to invoke the given version of this Lambda.
metric Return the given named metric for this Function.
metric_duration How long execution of this Lambda takes.
metric_errors How many invocations of this Lambda fail.
metric_invocations How often this Lambda is invoked.
metric_throttles How often this Lambda is throttled.
add_alias Defines an alias for this function.
add_environment Adds an environment variable to this Lambda function.
add_layers Adds one or more Lambda Layers to this Lambda function.
invalidate_version_based_on Mix additional information into the hash of the Version object.

to_string
def to_string() -> str

Returns a string representation of this construct.

apply_removal_policy
def apply_removal_policy(
  policy: RemovalPolicy
) -> None

Apply the given removal policy to this resource.

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

policyRequired
  • Type: aws_cdk.RemovalPolicy

add_event_source
def add_event_source(
  source: IEventSource
) -> None

Adds an event source to this function.

Event sources are implemented in the aws-cdk-lib/aws-lambda-event-sources module.

The following example adds an SQS Queue as an event source:

import { SqsEventSource } from 'aws-cdk-lib/aws-lambda-event-sources';
myFunction.addEventSource(new SqsEventSource(myQueue));

sourceRequired
  • Type: aws_cdk.aws_lambda.IEventSource

add_event_source_mapping
def add_event_source_mapping(
  id: str,
  batch_size: typing.Union[int, float] = None,
  bisect_batch_on_error: bool = None,
  enabled: bool = None,
  event_source_arn: str = None,
  filter_encryption: IKey = None,
  filters: typing.List[typing.Mapping[typing.Any]] = None,
  kafka_bootstrap_servers: typing.List[str] = None,
  kafka_consumer_group_id: str = None,
  kafka_topic: str = None,
  max_batching_window: Duration = None,
  max_concurrency: typing.Union[int, float] = None,
  max_record_age: Duration = None,
  on_failure: IEventSourceDlq = None,
  parallelization_factor: typing.Union[int, float] = None,
  report_batch_item_failures: bool = None,
  retry_attempts: typing.Union[int, float] = None,
  source_access_configurations: typing.List[SourceAccessConfiguration] = None,
  starting_position: StartingPosition = None,
  starting_position_timestamp: typing.Union[int, float] = None,
  support_s3_on_failure_destination: bool = None,
  tumbling_window: Duration = None
) -> EventSourceMapping

Adds an event source that maps to this AWS Lambda function.

idRequired
  • Type: str

batch_sizeOptional
  • Type: typing.Union[int, float]
  • Default: Amazon Kinesis, Amazon DynamoDB, and Amazon MSK is 100 records. The default for Amazon SQS is 10 messages. For standard SQS queues, the maximum is 10,000. For FIFO SQS queues, the maximum is 10.

The largest number of records that AWS Lambda will retrieve from your event source at the time of invoking your function.

Your function receives an event with all the retrieved records.

Valid Range: Minimum value of 1. Maximum value of 10000.


bisect_batch_on_errorOptional
  • Type: bool
  • Default: false

If the function returns an error, split the batch in two and retry.


enabledOptional
  • Type: bool
  • Default: true

Set to false to disable the event source upon creation.


event_source_arnOptional
  • Type: str
  • Default: not set if using a self managed Kafka cluster, throws an error otherwise

The Amazon Resource Name (ARN) of the event source.

Any record added to this stream can invoke the Lambda function.


filter_encryptionOptional
  • Type: aws_cdk.aws_kms.IKey
  • Default: none

Add Customer managed KMS key to encrypt Filter Criteria.

https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#aws-managed-cmk


filtersOptional
  • Type: typing.List[typing.Mapping[typing.Any]]
  • Default: none

Add filter criteria to Event Source.

https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html


kafka_bootstrap_serversOptional
  • Type: typing.List[str]
  • Default: none

A list of host and port pairs that are the addresses of the Kafka brokers in a self managed "bootstrap" Kafka cluster that a Kafka client connects to initially to bootstrap itself.

They are in the format abc.example.com:9096.


kafka_consumer_group_idOptional
  • Type: str
  • Default: none

The identifier for the Kafka consumer group to join.

The consumer group ID must be unique among all your Kafka event sources. After creating a Kafka event source mapping with the consumer group ID specified, you cannot update this value. The value must have a lenght between 1 and 200 and full the pattern '[a-zA-Z0-9-\/:_+=.@-]'. For more information, see Customizable consumer group ID.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-selfmanagedkafkaeventsourceconfig.html


kafka_topicOptional
  • Type: str
  • Default: no topic

The name of the Kafka topic.


max_batching_windowOptional
  • Type: aws_cdk.Duration
  • Default: Duration.seconds(0)

The maximum amount of time to gather records before invoking the function.

Maximum of Duration.minutes(5)


max_concurrencyOptional
  • Type: typing.Union[int, float]
  • Default: No specific limit.

The maximum concurrency setting limits the number of concurrent instances of the function that an Amazon SQS event source can invoke.

[https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#events-sqs-max-concurrency

Valid Range: Minimum value of 2. Maximum value of 1000.](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#events-sqs-max-concurrency

Valid Range: Minimum value of 2. Maximum value of 1000.)


max_record_ageOptional
  • Type: aws_cdk.Duration
  • Default: infinite or until the record expires.

The maximum age of a record that Lambda sends to a function for processing.

Valid Range: * Minimum value of 60 seconds * Maximum value of 7 days


on_failureOptional
  • Type: aws_cdk.aws_lambda.IEventSourceDlq
  • Default: discarded records are ignored

An Amazon SQS queue or Amazon SNS topic destination for discarded records.


parallelization_factorOptional
  • Type: typing.Union[int, float]
  • Default: 1

The number of batches to process from each shard concurrently.

Valid Range: * Minimum value of 1 * Maximum value of 10


report_batch_item_failuresOptional
  • Type: bool
  • Default: false

Allow functions to return partially successful responses for a batch of records.

https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-batchfailurereporting


retry_attemptsOptional
  • Type: typing.Union[int, float]
  • Default: infinite or until the record expires.

The maximum number of times to retry when the function returns an error.

Set to undefined if you want lambda to keep retrying infinitely or until the record expires.

Valid Range: * Minimum value of 0 * Maximum value of 10000


source_access_configurationsOptional
  • Type: typing.List[aws_cdk.aws_lambda.SourceAccessConfiguration]
  • Default: none

Specific settings like the authentication protocol or the VPC components to secure access to your event source.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-eventsourcemapping-sourceaccessconfiguration.html


starting_positionOptional
  • Type: aws_cdk.aws_lambda.StartingPosition
  • Default: no starting position

The position in the DynamoDB, Kinesis or MSK stream where AWS Lambda should start reading.

https://docs.aws.amazon.com/kinesis/latest/APIReference/API_GetShardIterator.html#Kinesis-GetShardIterator-request-ShardIteratorType


starting_position_timestampOptional
  • Type: typing.Union[int, float]
  • Default: no timestamp

The time from which to start reading, in Unix time seconds.


support_s3_on_failure_destinationOptional
  • Type: bool
  • Default: false

Check if support S3 onfailure destination(ODF).

Currently only MSK and self managed kafka event support S3 ODF


tumbling_windowOptional
  • Type: aws_cdk.Duration
  • Default: None

The size of the tumbling windows to group records sent to DynamoDB or Kinesis.

[https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-windows

Valid Range: 0 - 15 minutes](https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html#services-ddb-windows

Valid Range: 0 - 15 minutes)


add_function_url
def add_function_url(
  auth_type: FunctionUrlAuthType = None,
  cors: FunctionUrlCorsOptions = None,
  invoke_mode: InvokeMode = None
) -> FunctionUrl

Adds a url to this lambda function.

auth_typeOptional
  • Type: aws_cdk.aws_lambda.FunctionUrlAuthType
  • Default: FunctionUrlAuthType.AWS_IAM

The type of authentication that your function URL uses.


corsOptional
  • Type: aws_cdk.aws_lambda.FunctionUrlCorsOptions
  • Default: No CORS configuration.

The cross-origin resource sharing (CORS) settings for your function URL.


invoke_modeOptional
  • Type: aws_cdk.aws_lambda.InvokeMode
  • Default: InvokeMode.BUFFERED

The type of invocation mode that your Lambda function uses.


add_permission
def add_permission(
  id: str,
  principal: IPrincipal,
  action: str = None,
  event_source_token: str = None,
  function_url_auth_type: FunctionUrlAuthType = None,
  organization_id: str = None,
  scope: Construct = None,
  source_account: str = None,
  source_arn: str = None
) -> None

Adds a permission to the Lambda resource policy.

Permission for details.

idRequired
  • Type: str

The id for the permission construct.


principalRequired
  • Type: aws_cdk.aws_iam.IPrincipal

The entity for which you are granting permission to invoke the Lambda function.

This entity can be any of the following:

  • a valid AWS service principal, such as s3.amazonaws.com or sns.amazonaws.com
  • an AWS account ID for cross-account permissions. For example, you might want to allow a custom application in another AWS account to push events to Lambda by invoking your function.
  • an AWS organization principal to grant permissions to an entire organization.

The principal can be an AccountPrincipal, an ArnPrincipal, a ServicePrincipal, or an OrganizationPrincipal.


actionOptional
  • Type: str
  • Default: 'lambda:InvokeFunction'

The Lambda actions that you want to allow in this statement.

For example, you can specify lambda:CreateFunction to specify a certain action, or use a wildcard (lambda:*) to grant permission to all Lambda actions. For a list of actions, see Actions and Condition Context Keys for AWS Lambda in the IAM User Guide.


event_source_tokenOptional
  • Type: str
  • Default: The caller would not need to present a token.

A unique token that must be supplied by the principal invoking the function.


function_url_auth_typeOptional
  • Type: aws_cdk.aws_lambda.FunctionUrlAuthType
  • Default: No functionUrlAuthType

The authType for the function URL that you are granting permissions for.


organization_idOptional
  • Type: str
  • Default: No organizationId

The organization you want to grant permissions to.

Use this ONLY if you need to grant permissions to a subset of the organization. If you want to grant permissions to the entire organization, sending the organization principal through the principal property will suffice.

You can use this property to ensure that all source principals are owned by a specific organization.


scopeOptional
  • Type: constructs.Construct
  • Default: The instance of lambda.IFunction

The scope to which the permission constructs be attached.

The default is the Lambda function construct itself, but this would need to be different in cases such as cross-stack references where the Permissions would need to sit closer to the consumer of this permission (i.e., the caller).


source_accountOptional
  • Type: str

The AWS account ID (without hyphens) of the source owner.

For example, if you specify an S3 bucket in the SourceArn property, this value is the bucket owner's account ID. You can use this property to ensure that all source principals are owned by a specific account.


source_arnOptional
  • Type: str

The ARN of a resource that is invoking your function.

When granting Amazon Simple Storage Service (Amazon S3) permission to invoke your function, specify this property with the bucket ARN as its value. This ensures that events generated only from the specified bucket, not just any bucket from any AWS account that creates a mapping to your function, can invoke the function.


add_to_role_policy
def add_to_role_policy(
  statement: PolicyStatement
) -> None

Adds a statement to the IAM role assumed by the instance.

statementRequired
  • Type: aws_cdk.aws_iam.PolicyStatement

configure_async_invoke
def configure_async_invoke(
  max_event_age: Duration = None,
  on_failure: IDestination = None,
  on_success: IDestination = None,
  retry_attempts: typing.Union[int, float] = None
) -> None

Configures options for asynchronous invocation.

max_event_ageOptional
  • Type: aws_cdk.Duration
  • Default: Duration.hours(6)

The maximum age of a request that Lambda sends to a function for processing.

Minimum: 60 seconds Maximum: 6 hours


on_failureOptional
  • Type: aws_cdk.aws_lambda.IDestination
  • Default: no destination

The destination for failed invocations.


on_successOptional
  • Type: aws_cdk.aws_lambda.IDestination
  • Default: no destination

The destination for successful invocations.


retry_attemptsOptional
  • Type: typing.Union[int, float]
  • Default: 2

The maximum number of times to retry when the function returns an error.

Minimum: 0 Maximum: 2


consider_warning_on_invoke_function_permissions
def consider_warning_on_invoke_function_permissions(
  scope: Construct,
  action: str
) -> None

A warning will be added to functions under the following conditions: - permissions that include lambda:InvokeFunction are added to the unqualified function.

function.currentVersion is invoked before or after the permission is created.

This applies only to permissions on Lambda functions, not versions or aliases. This function is overridden as a noOp for QualifiedFunctionBase.

scopeRequired
  • Type: constructs.Construct

actionRequired
  • Type: str

grant_invoke
def grant_invoke(
  grantee: IGrantable
) -> Grant

Grant the given identity permissions to invoke this Lambda.

granteeRequired
  • Type: aws_cdk.aws_iam.IGrantable

grant_invoke_composite_principal
def grant_invoke_composite_principal(
  composite_principal: CompositePrincipal
) -> typing.List[Grant]

Grant multiple principals the ability to invoke this Lambda via CompositePrincipal.

composite_principalRequired
  • Type: aws_cdk.aws_iam.CompositePrincipal

grant_invoke_latest_version
def grant_invoke_latest_version(
  grantee: IGrantable
) -> Grant

Grant the given identity permissions to invoke the $LATEST version or unqualified version of this Lambda.

granteeRequired
  • Type: aws_cdk.aws_iam.IGrantable

grant_invoke_url
def grant_invoke_url(
  grantee: IGrantable
) -> Grant

Grant the given identity permissions to invoke this Lambda Function URL.

granteeRequired
  • Type: aws_cdk.aws_iam.IGrantable

grant_invoke_version
def grant_invoke_version(
  grantee: IGrantable,
  version: IVersion
) -> Grant

Grant the given identity permissions to invoke the given version of this Lambda.

granteeRequired
  • Type: aws_cdk.aws_iam.IGrantable

versionRequired
  • Type: aws_cdk.aws_lambda.IVersion

metric
def metric(
  metric_name: str,
  account: str = None,
  color: str = None,
  dimensions_map: typing.Mapping[str] = None,
  label: str = None,
  period: Duration = None,
  region: str = None,
  statistic: str = None,
  unit: Unit = None
) -> Metric

Return the given named metric for this Function.

metric_nameRequired
  • Type: str

accountOptional
  • Type: str
  • Default: Deployment account.

Account which this metric comes from.


colorOptional
  • Type: str
  • Default: Automatic color

The hex color code, prefixed with '#' (e.g. '#00ff00'), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here.


dimensions_mapOptional
  • Type: typing.Mapping[str]
  • Default: No dimensions.

Dimensions of the metric.


labelOptional
  • Type: str
  • Default: No label

Label for this metric when added to a Graph in a Dashboard.

You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:

[max: ${MAX}] MyMetric

As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph's legend.


periodOptional
  • Type: aws_cdk.Duration
  • Default: Duration.minutes(5)

The period over which the specified statistic is applied.


regionOptional
  • Type: str
  • Default: Deployment region.

Region which this metric comes from.


statisticOptional
  • Type: str
  • Default: Average

What function to use for aggregating.

Use the aws_cloudwatch.Stats helper class to construct valid input strings.

Can be one of the following:

  • "Minimum" | "min"
  • "Maximum" | "max"
  • "Average" | "avg"
  • "Sum" | "sum"
  • "SampleCount | "n"
  • "pNN.NN"
  • "tmNN.NN" | "tm(NN.NN%:NN.NN%)"
  • "iqm"
  • "wmNN.NN" | "wm(NN.NN%:NN.NN%)"
  • "tcNN.NN" | "tc(NN.NN%:NN.NN%)"
  • "tsNN.NN" | "ts(NN.NN%:NN.NN%)"

unitOptional
  • Type: aws_cdk.aws_cloudwatch.Unit
  • Default: All metric datums in the given metric stream

Unit used to filter the metric stream.

Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units.

The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases.

CloudWatch does not honor this property for graphs.


metric_duration
def metric_duration(
  account: str = None,
  color: str = None,
  dimensions_map: typing.Mapping[str] = None,
  label: str = None,
  period: Duration = None,
  region: str = None,
  statistic: str = None,
  unit: Unit = None
) -> Metric

How long execution of this Lambda takes.

Average over 5 minutes

accountOptional
  • Type: str
  • Default: Deployment account.

Account which this metric comes from.


colorOptional
  • Type: str
  • Default: Automatic color

The hex color code, prefixed with '#' (e.g. '#00ff00'), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here.


dimensions_mapOptional
  • Type: typing.Mapping[str]
  • Default: No dimensions.

Dimensions of the metric.


labelOptional
  • Type: str
  • Default: No label

Label for this metric when added to a Graph in a Dashboard.

You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:

[max: ${MAX}] MyMetric

As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph's legend.


periodOptional
  • Type: aws_cdk.Duration
  • Default: Duration.minutes(5)

The period over which the specified statistic is applied.


regionOptional
  • Type: str
  • Default: Deployment region.

Region which this metric comes from.


statisticOptional
  • Type: str
  • Default: Average

What function to use for aggregating.

Use the aws_cloudwatch.Stats helper class to construct valid input strings.

Can be one of the following:

  • "Minimum" | "min"
  • "Maximum" | "max"
  • "Average" | "avg"
  • "Sum" | "sum"
  • "SampleCount | "n"
  • "pNN.NN"
  • "tmNN.NN" | "tm(NN.NN%:NN.NN%)"
  • "iqm"
  • "wmNN.NN" | "wm(NN.NN%:NN.NN%)"
  • "tcNN.NN" | "tc(NN.NN%:NN.NN%)"
  • "tsNN.NN" | "ts(NN.NN%:NN.NN%)"

unitOptional
  • Type: aws_cdk.aws_cloudwatch.Unit
  • Default: All metric datums in the given metric stream

Unit used to filter the metric stream.

Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units.

The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases.

CloudWatch does not honor this property for graphs.


metric_errors
def metric_errors(
  account: str = None,
  color: str = None,
  dimensions_map: typing.Mapping[str] = None,
  label: str = None,
  period: Duration = None,
  region: str = None,
  statistic: str = None,
  unit: Unit = None
) -> Metric

How many invocations of this Lambda fail.

Sum over 5 minutes

accountOptional
  • Type: str
  • Default: Deployment account.

Account which this metric comes from.


colorOptional
  • Type: str
  • Default: Automatic color

The hex color code, prefixed with '#' (e.g. '#00ff00'), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here.


dimensions_mapOptional
  • Type: typing.Mapping[str]
  • Default: No dimensions.

Dimensions of the metric.


labelOptional
  • Type: str
  • Default: No label

Label for this metric when added to a Graph in a Dashboard.

You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:

[max: ${MAX}] MyMetric

As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph's legend.


periodOptional
  • Type: aws_cdk.Duration
  • Default: Duration.minutes(5)

The period over which the specified statistic is applied.


regionOptional
  • Type: str
  • Default: Deployment region.

Region which this metric comes from.


statisticOptional
  • Type: str
  • Default: Average

What function to use for aggregating.

Use the aws_cloudwatch.Stats helper class to construct valid input strings.

Can be one of the following:

  • "Minimum" | "min"
  • "Maximum" | "max"
  • "Average" | "avg"
  • "Sum" | "sum"
  • "SampleCount | "n"
  • "pNN.NN"
  • "tmNN.NN" | "tm(NN.NN%:NN.NN%)"
  • "iqm"
  • "wmNN.NN" | "wm(NN.NN%:NN.NN%)"
  • "tcNN.NN" | "tc(NN.NN%:NN.NN%)"
  • "tsNN.NN" | "ts(NN.NN%:NN.NN%)"

unitOptional
  • Type: aws_cdk.aws_cloudwatch.Unit
  • Default: All metric datums in the given metric stream

Unit used to filter the metric stream.

Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units.

The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases.

CloudWatch does not honor this property for graphs.


metric_invocations
def metric_invocations(
  account: str = None,
  color: str = None,
  dimensions_map: typing.Mapping[str] = None,
  label: str = None,
  period: Duration = None,
  region: str = None,
  statistic: str = None,
  unit: Unit = None
) -> Metric

How often this Lambda is invoked.

Sum over 5 minutes

accountOptional
  • Type: str
  • Default: Deployment account.

Account which this metric comes from.


colorOptional
  • Type: str
  • Default: Automatic color

The hex color code, prefixed with '#' (e.g. '#00ff00'), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here.


dimensions_mapOptional
  • Type: typing.Mapping[str]
  • Default: No dimensions.

Dimensions of the metric.


labelOptional
  • Type: str
  • Default: No label

Label for this metric when added to a Graph in a Dashboard.

You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:

[max: ${MAX}] MyMetric

As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph's legend.


periodOptional
  • Type: aws_cdk.Duration
  • Default: Duration.minutes(5)

The period over which the specified statistic is applied.


regionOptional
  • Type: str
  • Default: Deployment region.

Region which this metric comes from.


statisticOptional
  • Type: str
  • Default: Average

What function to use for aggregating.

Use the aws_cloudwatch.Stats helper class to construct valid input strings.

Can be one of the following:

  • "Minimum" | "min"
  • "Maximum" | "max"
  • "Average" | "avg"
  • "Sum" | "sum"
  • "SampleCount | "n"
  • "pNN.NN"
  • "tmNN.NN" | "tm(NN.NN%:NN.NN%)"
  • "iqm"
  • "wmNN.NN" | "wm(NN.NN%:NN.NN%)"
  • "tcNN.NN" | "tc(NN.NN%:NN.NN%)"
  • "tsNN.NN" | "ts(NN.NN%:NN.NN%)"

unitOptional
  • Type: aws_cdk.aws_cloudwatch.Unit
  • Default: All metric datums in the given metric stream

Unit used to filter the metric stream.

Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units.

The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases.

CloudWatch does not honor this property for graphs.


metric_throttles
def metric_throttles(
  account: str = None,
  color: str = None,
  dimensions_map: typing.Mapping[str] = None,
  label: str = None,
  period: Duration = None,
  region: str = None,
  statistic: str = None,
  unit: Unit = None
) -> Metric

How often this Lambda is throttled.

Sum over 5 minutes

accountOptional
  • Type: str
  • Default: Deployment account.

Account which this metric comes from.


colorOptional
  • Type: str
  • Default: Automatic color

The hex color code, prefixed with '#' (e.g. '#00ff00'), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here.


dimensions_mapOptional
  • Type: typing.Mapping[str]
  • Default: No dimensions.

Dimensions of the metric.


labelOptional
  • Type: str
  • Default: No label

Label for this metric when added to a Graph in a Dashboard.

You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:

[max: ${MAX}] MyMetric

As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph's legend.


periodOptional
  • Type: aws_cdk.Duration
  • Default: Duration.minutes(5)

The period over which the specified statistic is applied.


regionOptional
  • Type: str
  • Default: Deployment region.

Region which this metric comes from.


statisticOptional
  • Type: str
  • Default: Average

What function to use for aggregating.

Use the aws_cloudwatch.Stats helper class to construct valid input strings.

Can be one of the following:

  • "Minimum" | "min"
  • "Maximum" | "max"
  • "Average" | "avg"
  • "Sum" | "sum"
  • "SampleCount | "n"
  • "pNN.NN"
  • "tmNN.NN" | "tm(NN.NN%:NN.NN%)"
  • "iqm"
  • "wmNN.NN" | "wm(NN.NN%:NN.NN%)"
  • "tcNN.NN" | "tc(NN.NN%:NN.NN%)"
  • "tsNN.NN" | "ts(NN.NN%:NN.NN%)"

unitOptional
  • Type: aws_cdk.aws_cloudwatch.Unit
  • Default: All metric datums in the given metric stream

Unit used to filter the metric stream.

Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units.

The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases.

CloudWatch does not honor this property for graphs.


add_alias
def add_alias(
  alias_name: str,
  max_event_age: Duration = None,
  on_failure: IDestination = None,
  on_success: IDestination = None,
  retry_attempts: typing.Union[int, float] = None,
  additional_versions: typing.List[VersionWeight] = None,
  description: str = None,
  provisioned_concurrent_executions: typing.Union[int, float] = None
) -> Alias

Defines an alias for this function.

The alias will automatically be updated to point to the latest version of the function as it is being updated during a deployment.

declare const fn: lambda.Function;

fn.addAlias('Live');

// Is equivalent to

new lambda.Alias(this, 'AliasLive', {
  aliasName: 'Live',
  version: fn.currentVersion,
});
alias_nameRequired
  • Type: str

The name of the alias.


max_event_ageOptional
  • Type: aws_cdk.Duration
  • Default: Duration.hours(6)

The maximum age of a request that Lambda sends to a function for processing.

Minimum: 60 seconds Maximum: 6 hours


on_failureOptional
  • Type: aws_cdk.aws_lambda.IDestination
  • Default: no destination

The destination for failed invocations.


on_successOptional
  • Type: aws_cdk.aws_lambda.IDestination
  • Default: no destination

The destination for successful invocations.


retry_attemptsOptional
  • Type: typing.Union[int, float]
  • Default: 2

The maximum number of times to retry when the function returns an error.

Minimum: 0 Maximum: 2


additional_versionsOptional
  • Type: typing.List[aws_cdk.aws_lambda.VersionWeight]
  • Default: No additional versions

Additional versions with individual weights this alias points to.

Individual additional version weights specified here should add up to (less than) one. All remaining weight is routed to the default version.

For example, the config is

version: "1" additionalVersions: [{ version: "2", weight: 0.05 }]

Then 5% of traffic will be routed to function version 2, while the remaining 95% of traffic will be routed to function version 1.


descriptionOptional
  • Type: str
  • Default: No description

Description for the alias.


provisioned_concurrent_executionsOptional
  • Type: typing.Union[int, float]
  • Default: No provisioned concurrency

Specifies a provisioned concurrency configuration for a function's alias.


add_environment
def add_environment(
  key: str,
  value: str,
  remove_in_edge: bool = None
) -> Function

Adds an environment variable to this Lambda function.

If this is a ref to a Lambda function, this operation results in a no-op.

keyRequired
  • Type: str

The environment variable key.


valueRequired
  • Type: str

The environment variable's value.


remove_in_edgeOptional
  • Type: bool
  • Default: false - using the function in Lambda@Edge will throw

When used in Lambda@Edge via edgeArn() API, these environment variables will be removed.

If not set, an error will be thrown.

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-requirements-limits.html#lambda-requirements-lambda-function-configuration


add_layers
def add_layers(
  layers: ILayerVersion
) -> None

Adds one or more Lambda Layers to this Lambda function.

layersRequired
  • Type: aws_cdk.aws_lambda.ILayerVersion

the layers to be added.


invalidate_version_based_on
def invalidate_version_based_on(
  x: str
) -> None

Mix additional information into the hash of the Version object.

The Lambda Function construct does its best to automatically create a new Version when anything about the Function changes (its code, its layers, any of the other properties).

However, you can sometimes source information from places that the CDK cannot look into, like the deploy-time values of SSM parameters. In those cases, the CDK would not force the creation of a new Version object when it actually should.

This method can be used to invalidate the current Version object. Pass in any string into this method, and make sure the string changes when you know a new Version needs to be created.

This method may be called more than once.

xRequired
  • Type: str

Static Functions

Name Description
is_construct Checks if x is a construct.
is_owned_resource Returns true if the construct was created by CDK, and false otherwise.
is_resource Check whether the given construct is a Resource.
classify_version_property Record whether specific properties in the AWS::Lambda::Function resource should also be associated to the Version resource.
from_function_arn Import a lambda function into the CDK using its ARN.
from_function_attributes Creates a Lambda function object which represents a function not defined within this stack.
from_function_name Import a lambda function into the CDK using its name.
metric_all Return the given named metric for this Lambda.
metric_all_concurrent_executions Metric for the number of concurrent executions across all Lambdas.
metric_all_duration Metric for the Duration executing all Lambdas.
metric_all_errors Metric for the number of Errors executing all Lambdas.
metric_all_invocations Metric for the number of invocations of all Lambdas.
metric_all_throttles Metric for the number of throttled invocations of all Lambdas.
metric_all_unreserved_concurrent_executions Metric for the number of unreserved concurrent executions across all Lambdas.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SnapStartFunction.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


is_owned_resource
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SnapStartFunction.is_owned_resource(
  construct: IConstruct
)

Returns true if the construct was created by CDK, and false otherwise.

constructRequired
  • Type: constructs.IConstruct

is_resource
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SnapStartFunction.is_resource(
  construct: IConstruct
)

Check whether the given construct is a Resource.

constructRequired
  • Type: constructs.IConstruct

classify_version_property
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SnapStartFunction.classify_version_property(
  property_name: str,
  locked: bool
)

Record whether specific properties in the AWS::Lambda::Function resource should also be associated to the Version resource.

See 'currentVersion' section in the module README for more details.

property_nameRequired
  • Type: str

The property to classify.


lockedRequired
  • Type: bool

whether the property should be associated to the version or not.


from_function_arn
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SnapStartFunction.from_function_arn(
  scope: Construct,
  id: str,
  function_arn: str
)

Import a lambda function into the CDK using its ARN.

For Function.addPermissions() to work on this imported lambda, make sure that is in the same account and region as the stack you are importing it into.

scopeRequired
  • Type: constructs.Construct

idRequired
  • Type: str

function_arnRequired
  • Type: str

from_function_attributes
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SnapStartFunction.from_function_attributes(
  scope: Construct,
  id: str,
  function_arn: str,
  architecture: Architecture = None,
  role: IRole = None,
  same_environment: bool = None,
  security_group: ISecurityGroup = None,
  skip_permissions: bool = None
)

Creates a Lambda function object which represents a function not defined within this stack.

For Function.addPermissions() to work on this imported lambda, set the sameEnvironment property to true if this imported lambda is in the same account and region as the stack you are importing it into.

scopeRequired
  • Type: constructs.Construct

The parent construct.


idRequired
  • Type: str

The name of the lambda construct.


function_arnRequired
  • Type: str

The ARN of the Lambda function.

Format: arn::lambda:::function:


architectureOptional
  • Type: aws_cdk.aws_lambda.Architecture
  • Default: Architecture.X86_64

The architecture of this Lambda Function (this is an optional attribute and defaults to X86_64).


roleOptional
  • Type: aws_cdk.aws_iam.IRole

The IAM execution role associated with this function.

If the role is not specified, any role-related operations will no-op.


same_environmentOptional
  • Type: bool
  • Default: depends: true, if the Stack is configured with an explicit env (account and region) and the account is the same as this function. For environment-agnostic stacks this will default to false.

Setting this property informs the CDK that the imported function is in the same environment as the stack.

This affects certain behaviours such as, whether this function's permission can be modified. When not configured, the CDK attempts to auto-determine this. For environment agnostic stacks, i.e., stacks where the account is not specified with the env property, this is determined to be false.

Set this to property ONLY IF the imported function is in the same account as the stack it's imported in.


security_groupOptional
  • Type: aws_cdk.aws_ec2.ISecurityGroup

The security group of this Lambda, if in a VPC.

This needs to be given in order to support allowing connections to this Lambda.


skip_permissionsOptional
  • Type: bool
  • Default: false

Setting this property informs the CDK that the imported function ALREADY HAS the necessary permissions for what you are trying to do.

When not configured, the CDK attempts to auto-determine whether or not additional permissions are necessary on the function when grant APIs are used. If the CDK tried to add permissions on an imported lambda, it will fail.

Set this property ONLY IF you are committing to manage the imported function's permissions outside of CDK. You are acknowledging that your CDK code alone will have insufficient permissions to access the imported function.


from_function_name
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SnapStartFunction.from_function_name(
  scope: Construct,
  id: str,
  function_name: str
)

Import a lambda function into the CDK using its name.

scopeRequired
  • Type: constructs.Construct

idRequired
  • Type: str

function_nameRequired
  • Type: str

metric_all
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SnapStartFunction.metric_all(
  metric_name: str,
  account: str = None,
  color: str = None,
  dimensions_map: typing.Mapping[str] = None,
  label: str = None,
  period: Duration = None,
  region: str = None,
  statistic: str = None,
  unit: Unit = None
)

Return the given named metric for this Lambda.

metric_nameRequired
  • Type: str

accountOptional
  • Type: str
  • Default: Deployment account.

Account which this metric comes from.


colorOptional
  • Type: str
  • Default: Automatic color

The hex color code, prefixed with '#' (e.g. '#00ff00'), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here.


dimensions_mapOptional
  • Type: typing.Mapping[str]
  • Default: No dimensions.

Dimensions of the metric.


labelOptional
  • Type: str
  • Default: No label

Label for this metric when added to a Graph in a Dashboard.

You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:

[max: ${MAX}] MyMetric

As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph's legend.


periodOptional
  • Type: aws_cdk.Duration
  • Default: Duration.minutes(5)

The period over which the specified statistic is applied.


regionOptional
  • Type: str
  • Default: Deployment region.

Region which this metric comes from.


statisticOptional
  • Type: str
  • Default: Average

What function to use for aggregating.

Use the aws_cloudwatch.Stats helper class to construct valid input strings.

Can be one of the following:

  • "Minimum" | "min"
  • "Maximum" | "max"
  • "Average" | "avg"
  • "Sum" | "sum"
  • "SampleCount | "n"
  • "pNN.NN"
  • "tmNN.NN" | "tm(NN.NN%:NN.NN%)"
  • "iqm"
  • "wmNN.NN" | "wm(NN.NN%:NN.NN%)"
  • "tcNN.NN" | "tc(NN.NN%:NN.NN%)"
  • "tsNN.NN" | "ts(NN.NN%:NN.NN%)"

unitOptional
  • Type: aws_cdk.aws_cloudwatch.Unit
  • Default: All metric datums in the given metric stream

Unit used to filter the metric stream.

Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units.

The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases.

CloudWatch does not honor this property for graphs.


metric_all_concurrent_executions
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SnapStartFunction.metric_all_concurrent_executions(
  account: str = None,
  color: str = None,
  dimensions_map: typing.Mapping[str] = None,
  label: str = None,
  period: Duration = None,
  region: str = None,
  statistic: str = None,
  unit: Unit = None
)

Metric for the number of concurrent executions across all Lambdas.

accountOptional
  • Type: str
  • Default: Deployment account.

Account which this metric comes from.


colorOptional
  • Type: str
  • Default: Automatic color

The hex color code, prefixed with '#' (e.g. '#00ff00'), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here.


dimensions_mapOptional
  • Type: typing.Mapping[str]
  • Default: No dimensions.

Dimensions of the metric.


labelOptional
  • Type: str
  • Default: No label

Label for this metric when added to a Graph in a Dashboard.

You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:

[max: ${MAX}] MyMetric

As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph's legend.


periodOptional
  • Type: aws_cdk.Duration
  • Default: Duration.minutes(5)

The period over which the specified statistic is applied.


regionOptional
  • Type: str
  • Default: Deployment region.

Region which this metric comes from.


statisticOptional
  • Type: str
  • Default: Average

What function to use for aggregating.

Use the aws_cloudwatch.Stats helper class to construct valid input strings.

Can be one of the following:

  • "Minimum" | "min"
  • "Maximum" | "max"
  • "Average" | "avg"
  • "Sum" | "sum"
  • "SampleCount | "n"
  • "pNN.NN"
  • "tmNN.NN" | "tm(NN.NN%:NN.NN%)"
  • "iqm"
  • "wmNN.NN" | "wm(NN.NN%:NN.NN%)"
  • "tcNN.NN" | "tc(NN.NN%:NN.NN%)"
  • "tsNN.NN" | "ts(NN.NN%:NN.NN%)"

unitOptional
  • Type: aws_cdk.aws_cloudwatch.Unit
  • Default: All metric datums in the given metric stream

Unit used to filter the metric stream.

Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units.

The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases.

CloudWatch does not honor this property for graphs.


metric_all_duration
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SnapStartFunction.metric_all_duration(
  account: str = None,
  color: str = None,
  dimensions_map: typing.Mapping[str] = None,
  label: str = None,
  period: Duration = None,
  region: str = None,
  statistic: str = None,
  unit: Unit = None
)

Metric for the Duration executing all Lambdas.

accountOptional
  • Type: str
  • Default: Deployment account.

Account which this metric comes from.


colorOptional
  • Type: str
  • Default: Automatic color

The hex color code, prefixed with '#' (e.g. '#00ff00'), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here.


dimensions_mapOptional
  • Type: typing.Mapping[str]
  • Default: No dimensions.

Dimensions of the metric.


labelOptional
  • Type: str
  • Default: No label

Label for this metric when added to a Graph in a Dashboard.

You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:

[max: ${MAX}] MyMetric

As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph's legend.


periodOptional
  • Type: aws_cdk.Duration
  • Default: Duration.minutes(5)

The period over which the specified statistic is applied.


regionOptional
  • Type: str
  • Default: Deployment region.

Region which this metric comes from.


statisticOptional
  • Type: str
  • Default: Average

What function to use for aggregating.

Use the aws_cloudwatch.Stats helper class to construct valid input strings.

Can be one of the following:

  • "Minimum" | "min"
  • "Maximum" | "max"
  • "Average" | "avg"
  • "Sum" | "sum"
  • "SampleCount | "n"
  • "pNN.NN"
  • "tmNN.NN" | "tm(NN.NN%:NN.NN%)"
  • "iqm"
  • "wmNN.NN" | "wm(NN.NN%:NN.NN%)"
  • "tcNN.NN" | "tc(NN.NN%:NN.NN%)"
  • "tsNN.NN" | "ts(NN.NN%:NN.NN%)"

unitOptional
  • Type: aws_cdk.aws_cloudwatch.Unit
  • Default: All metric datums in the given metric stream

Unit used to filter the metric stream.

Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units.

The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases.

CloudWatch does not honor this property for graphs.


metric_all_errors
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SnapStartFunction.metric_all_errors(
  account: str = None,
  color: str = None,
  dimensions_map: typing.Mapping[str] = None,
  label: str = None,
  period: Duration = None,
  region: str = None,
  statistic: str = None,
  unit: Unit = None
)

Metric for the number of Errors executing all Lambdas.

accountOptional
  • Type: str
  • Default: Deployment account.

Account which this metric comes from.


colorOptional
  • Type: str
  • Default: Automatic color

The hex color code, prefixed with '#' (e.g. '#00ff00'), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here.


dimensions_mapOptional
  • Type: typing.Mapping[str]
  • Default: No dimensions.

Dimensions of the metric.


labelOptional
  • Type: str
  • Default: No label

Label for this metric when added to a Graph in a Dashboard.

You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:

[max: ${MAX}] MyMetric

As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph's legend.


periodOptional
  • Type: aws_cdk.Duration
  • Default: Duration.minutes(5)

The period over which the specified statistic is applied.


regionOptional
  • Type: str
  • Default: Deployment region.

Region which this metric comes from.


statisticOptional
  • Type: str
  • Default: Average

What function to use for aggregating.

Use the aws_cloudwatch.Stats helper class to construct valid input strings.

Can be one of the following:

  • "Minimum" | "min"
  • "Maximum" | "max"
  • "Average" | "avg"
  • "Sum" | "sum"
  • "SampleCount | "n"
  • "pNN.NN"
  • "tmNN.NN" | "tm(NN.NN%:NN.NN%)"
  • "iqm"
  • "wmNN.NN" | "wm(NN.NN%:NN.NN%)"
  • "tcNN.NN" | "tc(NN.NN%:NN.NN%)"
  • "tsNN.NN" | "ts(NN.NN%:NN.NN%)"

unitOptional
  • Type: aws_cdk.aws_cloudwatch.Unit
  • Default: All metric datums in the given metric stream

Unit used to filter the metric stream.

Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units.

The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases.

CloudWatch does not honor this property for graphs.


metric_all_invocations
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SnapStartFunction.metric_all_invocations(
  account: str = None,
  color: str = None,
  dimensions_map: typing.Mapping[str] = None,
  label: str = None,
  period: Duration = None,
  region: str = None,
  statistic: str = None,
  unit: Unit = None
)

Metric for the number of invocations of all Lambdas.

accountOptional
  • Type: str
  • Default: Deployment account.

Account which this metric comes from.


colorOptional
  • Type: str
  • Default: Automatic color

The hex color code, prefixed with '#' (e.g. '#00ff00'), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here.


dimensions_mapOptional
  • Type: typing.Mapping[str]
  • Default: No dimensions.

Dimensions of the metric.


labelOptional
  • Type: str
  • Default: No label

Label for this metric when added to a Graph in a Dashboard.

You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:

[max: ${MAX}] MyMetric

As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph's legend.


periodOptional
  • Type: aws_cdk.Duration
  • Default: Duration.minutes(5)

The period over which the specified statistic is applied.


regionOptional
  • Type: str
  • Default: Deployment region.

Region which this metric comes from.


statisticOptional
  • Type: str
  • Default: Average

What function to use for aggregating.

Use the aws_cloudwatch.Stats helper class to construct valid input strings.

Can be one of the following:

  • "Minimum" | "min"
  • "Maximum" | "max"
  • "Average" | "avg"
  • "Sum" | "sum"
  • "SampleCount | "n"
  • "pNN.NN"
  • "tmNN.NN" | "tm(NN.NN%:NN.NN%)"
  • "iqm"
  • "wmNN.NN" | "wm(NN.NN%:NN.NN%)"
  • "tcNN.NN" | "tc(NN.NN%:NN.NN%)"
  • "tsNN.NN" | "ts(NN.NN%:NN.NN%)"

unitOptional
  • Type: aws_cdk.aws_cloudwatch.Unit
  • Default: All metric datums in the given metric stream

Unit used to filter the metric stream.

Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units.

The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases.

CloudWatch does not honor this property for graphs.


metric_all_throttles
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SnapStartFunction.metric_all_throttles(
  account: str = None,
  color: str = None,
  dimensions_map: typing.Mapping[str] = None,
  label: str = None,
  period: Duration = None,
  region: str = None,
  statistic: str = None,
  unit: Unit = None
)

Metric for the number of throttled invocations of all Lambdas.

accountOptional
  • Type: str
  • Default: Deployment account.

Account which this metric comes from.


colorOptional
  • Type: str
  • Default: Automatic color

The hex color code, prefixed with '#' (e.g. '#00ff00'), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here.


dimensions_mapOptional
  • Type: typing.Mapping[str]
  • Default: No dimensions.

Dimensions of the metric.


labelOptional
  • Type: str
  • Default: No label

Label for this metric when added to a Graph in a Dashboard.

You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:

[max: ${MAX}] MyMetric

As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph's legend.


periodOptional
  • Type: aws_cdk.Duration
  • Default: Duration.minutes(5)

The period over which the specified statistic is applied.


regionOptional
  • Type: str
  • Default: Deployment region.

Region which this metric comes from.


statisticOptional
  • Type: str
  • Default: Average

What function to use for aggregating.

Use the aws_cloudwatch.Stats helper class to construct valid input strings.

Can be one of the following:

  • "Minimum" | "min"
  • "Maximum" | "max"
  • "Average" | "avg"
  • "Sum" | "sum"
  • "SampleCount | "n"
  • "pNN.NN"
  • "tmNN.NN" | "tm(NN.NN%:NN.NN%)"
  • "iqm"
  • "wmNN.NN" | "wm(NN.NN%:NN.NN%)"
  • "tcNN.NN" | "tc(NN.NN%:NN.NN%)"
  • "tsNN.NN" | "ts(NN.NN%:NN.NN%)"

unitOptional
  • Type: aws_cdk.aws_cloudwatch.Unit
  • Default: All metric datums in the given metric stream

Unit used to filter the metric stream.

Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units.

The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases.

CloudWatch does not honor this property for graphs.


metric_all_unreserved_concurrent_executions
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.SnapStartFunction.metric_all_unreserved_concurrent_executions(
  account: str = None,
  color: str = None,
  dimensions_map: typing.Mapping[str] = None,
  label: str = None,
  period: Duration = None,
  region: str = None,
  statistic: str = None,
  unit: Unit = None
)

Metric for the number of unreserved concurrent executions across all Lambdas.

accountOptional
  • Type: str
  • Default: Deployment account.

Account which this metric comes from.


colorOptional
  • Type: str
  • Default: Automatic color

The hex color code, prefixed with '#' (e.g. '#00ff00'), to use when this metric is rendered on a graph. The Color class has a set of standard colors that can be used here.


dimensions_mapOptional
  • Type: typing.Mapping[str]
  • Default: No dimensions.

Dimensions of the metric.


labelOptional
  • Type: str
  • Default: No label

Label for this metric when added to a Graph in a Dashboard.

You can use dynamic labels to show summary information about the entire displayed time series in the legend. For example, if you use:

[max: ${MAX}] MyMetric

As the metric label, the maximum value in the visible range will be shown next to the time series name in the graph's legend.


periodOptional
  • Type: aws_cdk.Duration
  • Default: Duration.minutes(5)

The period over which the specified statistic is applied.


regionOptional
  • Type: str
  • Default: Deployment region.

Region which this metric comes from.


statisticOptional
  • Type: str
  • Default: Average

What function to use for aggregating.

Use the aws_cloudwatch.Stats helper class to construct valid input strings.

Can be one of the following:

  • "Minimum" | "min"
  • "Maximum" | "max"
  • "Average" | "avg"
  • "Sum" | "sum"
  • "SampleCount | "n"
  • "pNN.NN"
  • "tmNN.NN" | "tm(NN.NN%:NN.NN%)"
  • "iqm"
  • "wmNN.NN" | "wm(NN.NN%:NN.NN%)"
  • "tcNN.NN" | "tc(NN.NN%:NN.NN%)"
  • "tsNN.NN" | "ts(NN.NN%:NN.NN%)"

unitOptional
  • Type: aws_cdk.aws_cloudwatch.Unit
  • Default: All metric datums in the given metric stream

Unit used to filter the metric stream.

Only refer to datums emitted to the metric stream with the given unit and ignore all others. Only useful when datums are being emitted to the same metric stream under different units.

The default is to use all matric datums in the stream, regardless of unit, which is recommended in nearly all cases.

CloudWatch does not honor this property for graphs.


Properties

Name Type Description
node constructs.Node The tree node.
env aws_cdk.ResourceEnvironment The environment this resource belongs to.
stack aws_cdk.Stack The stack in which this resource is defined.
architecture aws_cdk.aws_lambda.Architecture The architecture of this Lambda Function (this is an optional attribute and defaults to X86_64).
connections aws_cdk.aws_ec2.Connections Access the Connections object.
function_arn str ARN of this function.
function_name str Name of this function.
grant_principal aws_cdk.aws_iam.IPrincipal The principal this Lambda Function is running as.
is_bound_to_vpc bool Whether or not this Lambda function was bound to a VPC.
latest_version aws_cdk.aws_lambda.IVersion The $LATEST version of this function.
permissions_node constructs.Node The construct node where permissions are attached.
resource_arns_for_grant_invoke typing.List[str] The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().
role aws_cdk.aws_iam.IRole Execution role associated with this function.
current_version aws_cdk.aws_lambda.Version Returns a lambda.Version which represents the current version of this Lambda function. A new version will be created every time the function's configuration changes.
log_group aws_cdk.aws_logs.ILogGroup The LogGroup where the Lambda function's logs are made available.
runtime aws_cdk.aws_lambda.Runtime The runtime configured for this lambda.
dead_letter_queue aws_cdk.aws_sqs.IQueue The DLQ (as queue) associated with this Lambda Function (this is an optional attribute).
dead_letter_topic aws_cdk.aws_sns.ITopic The DLQ (as topic) associated with this Lambda Function (this is an optional attribute).
timeout aws_cdk.Duration The timeout configured for this lambda.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


envRequired
env: ResourceEnvironment
  • Type: aws_cdk.ResourceEnvironment

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.


stackRequired
stack: Stack
  • Type: aws_cdk.Stack

The stack in which this resource is defined.


architectureRequired
architecture: Architecture
  • Type: aws_cdk.aws_lambda.Architecture

The architecture of this Lambda Function (this is an optional attribute and defaults to X86_64).


connectionsRequired
connections: Connections
  • Type: aws_cdk.aws_ec2.Connections

Access the Connections object.

Will fail if not a VPC-enabled Lambda Function


function_arnRequired
function_arn: str
  • Type: str

ARN of this function.


function_nameRequired
function_name: str
  • Type: str

Name of this function.


grant_principalRequired
grant_principal: IPrincipal
  • Type: aws_cdk.aws_iam.IPrincipal

The principal this Lambda Function is running as.


is_bound_to_vpcRequired
is_bound_to_vpc: bool
  • Type: bool

Whether or not this Lambda function was bound to a VPC.

If this is is false, trying to access the connections object will fail.


latest_versionRequired
latest_version: IVersion
  • Type: aws_cdk.aws_lambda.IVersion

The $LATEST version of this function.

Note that this is reference to a non-specific AWS Lambda version, which means the function this version refers to can return different results in different invocations.

To obtain a reference to an explicit version which references the current function configuration, use lambdaFunction.currentVersion instead.


permissions_nodeRequired
permissions_node: Node
  • Type: constructs.Node

The construct node where permissions are attached.


resource_arns_for_grant_invokeRequired
resource_arns_for_grant_invoke: typing.List[str]
  • Type: typing.List[str]

The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke().


roleOptional
role: IRole
  • Type: aws_cdk.aws_iam.IRole

Execution role associated with this function.


current_versionRequired
current_version: Version
  • Type: aws_cdk.aws_lambda.Version

Returns a lambda.Version which represents the current version of this Lambda function. A new version will be created every time the function's configuration changes.

You can specify options for this version using the currentVersionOptions prop when initializing the lambda.Function.


log_groupRequired
log_group: ILogGroup
  • Type: aws_cdk.aws_logs.ILogGroup

The LogGroup where the Lambda function's logs are made available.

If either logRetention is set or this property is called, a CloudFormation custom resource is added to the stack that pre-creates the log group as part of the stack deployment, if it already doesn't exist, and sets the correct log retention period (never expire, by default).

Further, if the log group already exists and the logRetention is not set, the custom resource will reset the log retention to never expire even if it was configured with a different value.


runtimeRequired
runtime: Runtime
  • Type: aws_cdk.aws_lambda.Runtime

The runtime configured for this lambda.


dead_letter_queueOptional
dead_letter_queue: IQueue
  • Type: aws_cdk.aws_sqs.IQueue

The DLQ (as queue) associated with this Lambda Function (this is an optional attribute).


dead_letter_topicOptional
dead_letter_topic: ITopic
  • Type: aws_cdk.aws_sns.ITopic

The DLQ (as topic) associated with this Lambda Function (this is an optional attribute).


timeoutOptional
timeout: Duration
  • Type: aws_cdk.Duration

The timeout configured for this lambda.


TypeSafeApiAsyncModelBuild

Adds a task to convert the OpenAPI specification into an AsyncAPI specification, which can be used for documentation generation.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSafeApiAsyncModelBuild(
  project: Project,
  async_api_spec_file: str,
  parsed_spec_file: str
)
Name Type Description
project projen.Project No description.
async_api_spec_file str Path to the generated AsyncAPI specification (relative to the project root).
parsed_spec_file str Path of the parsed/bundled OpenAPI specification (relative to the project root).

projectRequired
  • Type: projen.Project

async_api_spec_fileRequired
  • Type: str

Path to the generated AsyncAPI specification (relative to the project root).


parsed_spec_fileRequired
  • Type: str

Path of the parsed/bundled OpenAPI specification (relative to the project root).


Methods

Name Description
to_string Returns a string representation of this construct.
post_synthesize Called after synthesis.
pre_synthesize Called before synthesis.
synthesize Synthesizes files to the project output directory.

to_string
def to_string() -> str

Returns a string representation of this construct.

post_synthesize
def post_synthesize() -> None

Called after synthesis.

Order is not guaranteed.

pre_synthesize
def pre_synthesize() -> None

Called before synthesis.

synthesize
def synthesize() -> None

Synthesizes files to the project output directory.

Static Functions

Name Description
is_construct Checks if x is a construct.
is_component Test whether the given construct is a component.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSafeApiAsyncModelBuild.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


is_component
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSafeApiAsyncModelBuild.is_component(
  x: typing.Any
)

Test whether the given construct is a component.

xRequired
  • Type: typing.Any

Properties

Name Type Description
node constructs.Node The tree node.
project projen.Project No description.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


projectRequired
project: Project
  • Type: projen.Project

TypeSafeApiModelBuild

Adds the build task for parsing/bundling an OpenAPI spec ready for use by code generation projects.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSafeApiModelBuild(
  project: Project,
  parsed_spec_file: str,
  open_api_specification_path: str,
  smithy_json_model_path: str = None
)
Name Type Description
project projen.Project No description.
parsed_spec_file str Path of the parsed/bundled OpenAPI specification (relative to the project root).
open_api_specification_path str Path to the OpenAPI specification.
smithy_json_model_path str Optional path to the Smithy JSON model (for Smithy projects only).

projectRequired
  • Type: projen.Project

parsed_spec_fileRequired
  • Type: str

Path of the parsed/bundled OpenAPI specification (relative to the project root).


open_api_specification_pathRequired
  • Type: str

Path to the OpenAPI specification.


smithy_json_model_pathOptional
  • Type: str

Optional path to the Smithy JSON model (for Smithy projects only).


Methods

Name Description
to_string Returns a string representation of this construct.
post_synthesize Called after synthesis.
pre_synthesize Called before synthesis.
synthesize Synthesizes files to the project output directory.

to_string
def to_string() -> str

Returns a string representation of this construct.

post_synthesize
def post_synthesize() -> None

Called after synthesis.

Order is not guaranteed.

pre_synthesize
def pre_synthesize() -> None

Called before synthesis.

synthesize
def synthesize() -> None

Synthesizes files to the project output directory.

Static Functions

Name Description
is_construct Checks if x is a construct.
is_component Test whether the given construct is a component.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSafeApiModelBuild.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


is_component
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSafeApiModelBuild.is_component(
  x: typing.Any
)

Test whether the given construct is a component.

xRequired
  • Type: typing.Any

Properties

Name Type Description
node constructs.Node The tree node.
project projen.Project No description.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


projectRequired
project: Project
  • Type: projen.Project

TypeSafeApiProject

Project for a type-safe API, defined using Smithy or OpenAPI.

Generates a CDK construct to deploy your API, as well as client and server code to help build your API quickly.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSafeApiProject(
  name: str,
  commit_generated: bool = None,
  git_ignore_options: IgnoreFileOptions = None,
  git_options: GitOptions = None,
  logging: LoggerOptions = None,
  outdir: str = None,
  parent: Project = None,
  projen_command: str = None,
  projenrc_json: bool = None,
  projenrc_json_options: ProjenrcJsonOptions = None,
  renovatebot: bool = None,
  renovatebot_options: RenovatebotOptions = None,
  infrastructure: InfrastructureConfiguration,
  model: ModelConfiguration,
  commit_generated_code: bool = None,
  documentation: DocumentationConfiguration = None,
  handlers: HandlersConfiguration = None,
  library: LibraryConfiguration = None,
  runtime: RuntimeConfiguration = None
)
Name Type Description
name str This is the name of your project.
commit_generated bool Whether to commit the managed files by default.
git_ignore_options projen.IgnoreFileOptions Configuration options for .gitignore file.
git_options projen.GitOptions Configuration options for git.
logging projen.LoggerOptions Configure logging options such as verbosity.
outdir str The root directory of the project.
parent projen.Project The parent project, if this project is part of a bigger project.
projen_command str The shell command to use in order to run the projen CLI.
projenrc_json bool Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.
projenrc_json_options projen.ProjenrcJsonOptions Options for .projenrc.json.
renovatebot bool Use renovatebot to handle dependency upgrades.
renovatebot_options projen.RenovatebotOptions Options for renovatebot.
infrastructure InfrastructureConfiguration Configuration for generated infrastructure.
model ModelConfiguration Configuration for the API model.
commit_generated_code bool Whether to commit the code generated by the OpenAPI Generator.
documentation DocumentationConfiguration Configuration for generated documentation.
handlers HandlersConfiguration Configuration for lambda handlers for implementing the API.
library LibraryConfiguration Configuration for generated libraries.
runtime RuntimeConfiguration Configuration for generated runtime projects (containing types, clients and server code).

nameRequired
  • Type: str
  • Default: $BASEDIR

This is the name of your project.


commit_generatedOptional
  • Type: bool
  • Default: true

Whether to commit the managed files by default.


git_ignore_optionsOptional
  • Type: projen.IgnoreFileOptions

Configuration options for .gitignore file.


git_optionsOptional
  • Type: projen.GitOptions

Configuration options for git.


loggingOptional
  • Type: projen.LoggerOptions
  • Default: {}

Configure logging options such as verbosity.


outdirOptional
  • Type: str
  • Default: "."

The root directory of the project.

Relative to this directory, all files are synthesized.

If this project has a parent, this directory is relative to the parent directory and it cannot be the same as the parent or any of it's other subprojects.


parentOptional
  • Type: projen.Project

The parent project, if this project is part of a bigger project.


projen_commandOptional
  • Type: str
  • Default: "npx projen"

The shell command to use in order to run the projen CLI.

Can be used to customize in special environments.


projenrc_jsonOptional
  • Type: bool
  • Default: false

Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.


projenrc_json_optionsOptional
  • Type: projen.ProjenrcJsonOptions
  • Default: default options

Options for .projenrc.json.


renovatebotOptional
  • Type: bool
  • Default: false

Use renovatebot to handle dependency upgrades.


renovatebot_optionsOptional
  • Type: projen.RenovatebotOptions
  • Default: default options

Options for renovatebot.


infrastructureRequired

Configuration for generated infrastructure.


modelRequired

Configuration for the API model.


commit_generated_codeOptional
  • Type: bool
  • Default: false

Whether to commit the code generated by the OpenAPI Generator.


documentationOptional

Configuration for generated documentation.


handlersOptional

Configuration for lambda handlers for implementing the API.


libraryOptional

Configuration for generated libraries.

Libraries are projects which are generated from your model, but are not fully-fledged runtimes, for example react hooks or clients in languages that aren't supported as runtimes.


runtimeOptional

Configuration for generated runtime projects (containing types, clients and server code).


Methods

Name Description
to_string Returns a string representation of this construct.
add_exclude_from_cleanup Exclude the matching files from pre-synth cleanup.
add_git_ignore Adds a .gitignore pattern.
add_package_ignore Exclude these files from the bundled package.
add_task Adds a new task to this project.
add_tip Prints a "tip" message during synthesis.
annotate_generated Consider a set of files as "generated".
post_synthesize Called after all components are synthesized.
pre_synthesize Called before all components are synthesized.
remove_task Removes a task from a project.
run_task_command Returns the shell command to execute in order to run a task.
synth Synthesize all project files into outdir.
try_find_file Finds a file at the specified relative path within this project and all its subprojects.
try_find_json_file Finds a json file by name.
try_find_object_file Finds an object file (like JsonFile, YamlFile, etc.) by name.
try_remove_file Finds a file at the specified relative path within this project and removes it.

to_string
def to_string() -> str

Returns a string representation of this construct.

add_exclude_from_cleanup
def add_exclude_from_cleanup(
  globs: str
) -> None

Exclude the matching files from pre-synth cleanup.

Can be used when, for example, some source files include the projen marker and we don't want them to be erased during synth.

globsRequired
  • Type: str

The glob patterns to match.


add_git_ignore
def add_git_ignore(
  pattern: str
) -> None

Adds a .gitignore pattern.

patternRequired
  • Type: str

The glob pattern to ignore.


add_package_ignore
def add_package_ignore(
  _pattern: str
) -> None

Exclude these files from the bundled package.

Implemented by project types based on the packaging mechanism. For example, NodeProject delegates this to .npmignore.

_patternRequired
  • Type: str

The glob pattern to exclude.


add_task
def add_task(
  name: str,
  condition: str = None,
  cwd: str = None,
  description: str = None,
  env: typing.Mapping[str] = None,
  required_env: typing.List[str] = None,
  args: typing.List[str] = None,
  exec: str = None,
  receive_args: bool = None,
  steps: typing.List[TaskStep] = None
) -> Task

Adds a new task to this project.

This will fail if the project already has a task with this name.

nameRequired
  • Type: str

The task name to add.


conditionOptional
  • Type: str

A shell command which determines if the this task should be executed.

If the program exits with a zero exit code, steps will be executed. A non-zero code means that task will be skipped.


cwdOptional
  • Type: str
  • Default: process.cwd()

The working directory for all steps in this task (unless overridden by the step).


descriptionOptional
  • Type: str
  • Default: the task name

The description of this build command.


envOptional
  • Type: typing.Mapping[str]
  • Default: {}

Defines environment variables for the execution of this task.

Values in this map will be evaluated in a shell, so you can do stuff like $(echo "foo").


required_envOptional
  • Type: typing.List[str]

A set of environment variables that must be defined in order to execute this task.

Task execution will fail if one of these is not defined.


argsOptional
  • Type: typing.List[str]
  • Default: no arguments are passed to the step

Should the provided exec shell command receive fixed args.

{@link TaskStepOptions.args }


execOptional
  • Type: str
  • Default: add steps using task.exec(command) or task.spawn(subtask)

Shell command to execute as the first command of the task.


receive_argsOptional
  • Type: bool
  • Default: false

Should the provided exec shell command receive args passed to the task.

{@link TaskStepOptions.receiveArgs }


stepsOptional
  • Type: typing.List[projen.TaskStep]

List of task steps to run.


~~add_tip~~
def add_tip(
  message: str
) -> None

Prints a "tip" message during synthesis.

messageRequired
  • Type: str

The message.


annotate_generated
def annotate_generated(
  _glob: str
) -> None

Consider a set of files as "generated".

This method is implemented by derived classes and used for example, to add git attributes to tell GitHub that certain files are generated.

_globRequired
  • Type: str

the glob pattern to match (could be a file path).


post_synthesize
def post_synthesize() -> None

Called after all components are synthesized.

Order is not guaranteed.

pre_synthesize
def pre_synthesize() -> None

Called before all components are synthesized.

remove_task
def remove_task(
  name: str
) -> Task

Removes a task from a project.

nameRequired
  • Type: str

The name of the task to remove.


run_task_command
def run_task_command(
  task: Task
) -> str

Returns the shell command to execute in order to run a task.

By default, this is npx projen@<version> <task>

taskRequired
  • Type: projen.Task

The task for which the command is required.


synth
def synth() -> None

Synthesize all project files into outdir.

  1. Call "this.preSynthesize()"
  2. Delete all generated files
  3. Synthesize all subprojects
  4. Synthesize all components of this project
  5. Call "postSynthesize()" for all components of this project
  6. Call "this.postSynthesize()"
try_find_file
def try_find_file(
  file_path: str
) -> FileBase

Finds a file at the specified relative path within this project and all its subprojects.

file_pathRequired
  • Type: str

The file path.

If this path is relative, it will be resolved from the root of this project.


~~try_find_json_file~~
def try_find_json_file(
  file_path: str
) -> JsonFile

Finds a json file by name.

file_pathRequired
  • Type: str

The file path.


try_find_object_file
def try_find_object_file(
  file_path: str
) -> ObjectFile

Finds an object file (like JsonFile, YamlFile, etc.) by name.

file_pathRequired
  • Type: str

The file path.


try_remove_file
def try_remove_file(
  file_path: str
) -> FileBase

Finds a file at the specified relative path within this project and removes it.

file_pathRequired
  • Type: str

The file path.

If this path is relative, it will be resolved from the root of this project.


Static Functions

Name Description
is_construct Checks if x is a construct.
is_project Test whether the given construct is a project.
of Find the closest ancestor project for given construct.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSafeApiProject.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


is_project
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSafeApiProject.is_project(
  x: typing.Any
)

Test whether the given construct is a project.

xRequired
  • Type: typing.Any

of
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSafeApiProject.of(
  construct: IConstruct
)

Find the closest ancestor project for given construct.

When given a project, this it the project itself.

constructRequired
  • Type: constructs.IConstruct

Properties

Name Type Description
node constructs.Node The tree node.
build_task projen.Task No description.
commit_generated bool Whether to commit the managed files by default.
compile_task projen.Task No description.
components typing.List[projen.Component] Returns all the components within this project.
deps projen.Dependencies Project dependencies.
ejected bool Whether or not the project is being ejected.
files typing.List[projen.FileBase] All files in this project.
gitattributes projen.GitAttributesFile The .gitattributes file for this repository.
gitignore projen.IgnoreFile .gitignore.
logger projen.Logger Logging utilities.
name str Project name.
outdir str Absolute output directory of this project.
package_task projen.Task No description.
post_compile_task projen.Task No description.
pre_compile_task projen.Task No description.
project_build projen.ProjectBuild Manages the build process of the project.
projen_command str The command to use in order to run the projen CLI.
root projen.Project The root project.
subprojects typing.List[projen.Project] Returns all the subprojects within this project.
tasks projen.Tasks Project tasks.
test_task projen.Task No description.
default_task projen.Task This is the "default" task, the one that executes "projen".
init_project projen.InitProject The options used when this project is bootstrapped via projen new.
parent projen.Project A parent project.
all ProjectCollections Collections of all sub-projects managed by this project.
documentation GeneratedDocumentationProjects Generated documentation projects.
handlers GeneratedCodeProjects Lambda handlers projects.
infrastructure GeneratedCodeProjects Generated infrastructure projects.
library GeneratedLibraryProjects Generated library projects.
model ModelProject Project for the api model.
runtime GeneratedCodeProjects Generated runtime projects.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


build_taskRequired
build_task: Task
  • Type: projen.Task

commit_generatedRequired
commit_generated: bool
  • Type: bool

Whether to commit the managed files by default.


compile_taskRequired
compile_task: Task
  • Type: projen.Task

componentsRequired
components: typing.List[Component]
  • Type: typing.List[projen.Component]

Returns all the components within this project.


depsRequired
deps: Dependencies
  • Type: projen.Dependencies

Project dependencies.


ejectedRequired
ejected: bool
  • Type: bool

Whether or not the project is being ejected.


filesRequired
files: typing.List[FileBase]
  • Type: typing.List[projen.FileBase]

All files in this project.


gitattributesRequired
gitattributes: GitAttributesFile
  • Type: projen.GitAttributesFile

The .gitattributes file for this repository.


gitignoreRequired
gitignore: IgnoreFile
  • Type: projen.IgnoreFile

.gitignore.


loggerRequired
logger: Logger
  • Type: projen.Logger

Logging utilities.


nameRequired
name: str
  • Type: str

Project name.


outdirRequired
outdir: str
  • Type: str

Absolute output directory of this project.


package_taskRequired
package_task: Task
  • Type: projen.Task

post_compile_taskRequired
post_compile_task: Task
  • Type: projen.Task

pre_compile_taskRequired
pre_compile_task: Task
  • Type: projen.Task

project_buildRequired
project_build: ProjectBuild
  • Type: projen.ProjectBuild

Manages the build process of the project.


projen_commandRequired
projen_command: str
  • Type: str

The command to use in order to run the projen CLI.


rootRequired
root: Project
  • Type: projen.Project

The root project.


subprojectsRequired
subprojects: typing.List[Project]
  • Type: typing.List[projen.Project]

Returns all the subprojects within this project.


tasksRequired
tasks: Tasks
  • Type: projen.Tasks

Project tasks.


test_taskRequired
test_task: Task
  • Type: projen.Task

default_taskOptional
default_task: Task
  • Type: projen.Task

This is the "default" task, the one that executes "projen".

Undefined if the project is being ejected.


init_projectOptional
init_project: InitProject
  • Type: projen.InitProject

The options used when this project is bootstrapped via projen new.

It includes the original set of options passed to the CLI and also the JSII FQN of the project type.


parentOptional
parent: Project
  • Type: projen.Project

A parent project.

If undefined, this is the root project.


allRequired
all: ProjectCollections

Collections of all sub-projects managed by this project.


documentationRequired
documentation: GeneratedDocumentationProjects

Generated documentation projects.

Only the properties corresponding to specified documentation.formats will be defined.


handlersRequired
handlers: GeneratedCodeProjects

Lambda handlers projects.

Only the properties corresponding to handlers.languages will be defined.


infrastructureRequired
infrastructure: GeneratedCodeProjects

Generated infrastructure projects.

Only the property corresponding to infrastructure.language will be defined.


libraryRequired
library: GeneratedLibraryProjects

Generated library projects.

Only the properties corresponding to specified library.libraries will be defined.


modelRequired
model: ModelProject

Project for the api model.


runtimeRequired
runtime: GeneratedCodeProjects

Generated runtime projects.

When runtime.languages includes the corresponding language, the project can be assumed to be defined.


Constants

Name Type Description
DEFAULT_TASK str The name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
DEFAULT_TASK: str
  • Type: str

The name of the default task (the task executed when projen is run without arguments).

Normally this task should synthesize the project files.


TypeSafeRestApi

A construct for creating an api gateway rest api based on the definition in the OpenAPI spec.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSafeRestApi(
  scope: Construct,
  id: str,
  cloud_watch_role: bool = None,
  cloud_watch_role_removal_policy: RemovalPolicy = None,
  deploy: bool = None,
  deploy_options: StageOptions = None,
  description: str = None,
  disable_execute_api_endpoint: bool = None,
  domain_name: DomainNameOptions = None,
  endpoint_export_name: str = None,
  endpoint_types: typing.List[EndpointType] = None,
  fail_on_warnings: bool = None,
  parameters: typing.Mapping[str] = None,
  policy: PolicyDocument = None,
  rest_api_name: str = None,
  retain_deployments: bool = None,
  integrations: typing.Mapping[TypeSafeApiIntegration],
  operation_lookup: typing.Mapping[OperationDetails],
  api_key_options: ApiKeyOptions = None,
  cors_options: CorsOptions = None,
  default_authorizer: Authorizer = None,
  spec_path: str,
  min_compression_size: Size = None,
  output_spec_bucket: IBucket = None,
  web_acl_options: TypeSafeApiWebAclOptions = None
)
Name Type Description
scope constructs.Construct No description.
id str No description.
cloud_watch_role bool Automatically configure an AWS CloudWatch role for API Gateway.
cloud_watch_role_removal_policy aws_cdk.RemovalPolicy The removal policy applied to the AWS CloudWatch role when this resource is removed from the application.
deploy bool Indicates if a Deployment should be automatically created for this API, and recreated when the API model (resources, methods) changes.
deploy_options aws_cdk.aws_apigateway.StageOptions Options for the API Gateway stage that will always point to the latest deployment when deploy is enabled.
description str A description of the RestApi construct.
disable_execute_api_endpoint bool Specifies whether clients can invoke the API using the default execute-api endpoint.
domain_name aws_cdk.aws_apigateway.DomainNameOptions Configure a custom domain name and map it to this API.
endpoint_export_name str Export name for the CfnOutput containing the API endpoint.
endpoint_types typing.List[aws_cdk.aws_apigateway.EndpointType] A list of the endpoint types of the API.
fail_on_warnings bool Indicates whether to roll back the resource if a warning occurs while API Gateway is creating the RestApi resource.
parameters typing.Mapping[str] Custom header parameters for the request.
policy aws_cdk.aws_iam.PolicyDocument A policy document that contains the permissions for this RestApi.
rest_api_name str A name for the API Gateway RestApi resource.
retain_deployments bool Retains old deployment resources when the API changes.
integrations typing.Mapping[TypeSafeApiIntegration] A mapping of API operation to its integration.
operation_lookup typing.Mapping[OperationDetails] Details about each operation.
api_key_options ApiKeyOptions Options for API keys.
cors_options aws_cdk.aws_apigateway.CorsOptions Cross Origin Resource Sharing options for the API.
default_authorizer Authorizer The default authorizer to use for your api.
spec_path str Path to the JSON open api spec.
min_compression_size aws_cdk.Size A Size(in bytes, kibibytes, mebibytes etc) that is used to enable compression (with non-negative between 0 and 10485760 (10M) bytes, inclusive) or disable compression (when undefined) on an API.
output_spec_bucket aws_cdk.aws_s3.IBucket By default, the spec is prepared and outputted into the CDK assets bucket.
web_acl_options TypeSafeApiWebAclOptions Options for the AWS WAF v2 WebACL associated with the api.

scopeRequired
  • Type: constructs.Construct

idRequired
  • Type: str

cloud_watch_roleOptional
  • Type: bool
  • Default: false if @aws-cdk/aws-apigateway:disableCloudWatchRole is enabled, true otherwise

Automatically configure an AWS CloudWatch role for API Gateway.


cloud_watch_role_removal_policyOptional
  • Type: aws_cdk.RemovalPolicy
  • Default: RemovalPolicy.RETAIN

The removal policy applied to the AWS CloudWatch role when this resource is removed from the application.

Requires cloudWatchRole to be enabled.


deployOptional
  • Type: bool
  • Default: true

Indicates if a Deployment should be automatically created for this API, and recreated when the API model (resources, methods) changes.

Since API Gateway deployments are immutable, When this option is enabled (by default), an AWS::ApiGateway::Deployment resource will automatically created with a logical ID that hashes the API model (methods, resources and options). This means that when the model changes, the logical ID of this CloudFormation resource will change, and a new deployment will be created.

If this is set, latestDeployment will refer to the Deployment object and deploymentStage will refer to a Stage that points to this deployment. To customize the stage options, use the deployOptions property.

A CloudFormation Output will also be defined with the root URL endpoint of this REST API.


deploy_optionsOptional
  • Type: aws_cdk.aws_apigateway.StageOptions
  • Default: Based on defaults of StageOptions.

Options for the API Gateway stage that will always point to the latest deployment when deploy is enabled.

If deploy is disabled, this value cannot be set.


descriptionOptional
  • Type: str
  • Default: 'Automatically created by the RestApi construct'

A description of the RestApi construct.


disable_execute_api_endpointOptional
  • Type: bool
  • Default: false

Specifies whether clients can invoke the API using the default execute-api endpoint.

To require that clients use a custom domain name to invoke the API, disable the default endpoint.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-apigateway-restapi.html


domain_nameOptional
  • Type: aws_cdk.aws_apigateway.DomainNameOptions
  • Default: no domain name is defined, use addDomainName or directly define a DomainName.

Configure a custom domain name and map it to this API.


endpoint_export_nameOptional
  • Type: str
  • Default: when no export name is given, output will be created without export

Export name for the CfnOutput containing the API endpoint.


endpoint_typesOptional
  • Type: typing.List[aws_cdk.aws_apigateway.EndpointType]
  • Default: EndpointType.EDGE

A list of the endpoint types of the API.

Use this property when creating an API.


fail_on_warningsOptional
  • Type: bool
  • Default: false

Indicates whether to roll back the resource if a warning occurs while API Gateway is creating the RestApi resource.


parametersOptional
  • Type: typing.Mapping[str]
  • Default: No parameters.

Custom header parameters for the request.

https://docs.aws.amazon.com/cli/latest/reference/apigateway/import-rest-api.html


policyOptional
  • Type: aws_cdk.aws_iam.PolicyDocument
  • Default: No policy.

A policy document that contains the permissions for this RestApi.


rest_api_nameOptional
  • Type: str
  • Default: ID of the RestApi construct.

A name for the API Gateway RestApi resource.


retain_deploymentsOptional
  • Type: bool
  • Default: false

Retains old deployment resources when the API changes.

This allows manually reverting stages to point to old deployments via the AWS Console.


integrationsRequired

A mapping of API operation to its integration.


operation_lookupRequired

Details about each operation.


api_key_optionsOptional

Options for API keys.


cors_optionsOptional
  • Type: aws_cdk.aws_apigateway.CorsOptions

Cross Origin Resource Sharing options for the API.


default_authorizerOptional

The default authorizer to use for your api.

When omitted, no default authorizer is used. Authorizers specified at the integration level will override this for that operation.


spec_pathRequired
  • Type: str

Path to the JSON open api spec.


min_compression_sizeOptional
  • Type: aws_cdk.Size
  • Default: Compression is disabled.

A Size(in bytes, kibibytes, mebibytes etc) that is used to enable compression (with non-negative between 0 and 10485760 (10M) bytes, inclusive) or disable compression (when undefined) on an API.

When compression is enabled, compression or decompression is not applied on the payload if the payload size is smaller than this value. Setting it to zero allows compression for any payload size.


output_spec_bucketOptional
  • Type: aws_cdk.aws_s3.IBucket

By default, the spec is prepared and outputted into the CDK assets bucket.

If this is undesired, use this option to specify the output bucket.


web_acl_optionsOptional

Options for the AWS WAF v2 WebACL associated with the api.

By default, a Web ACL with the AWS default managed rule set will be associated with the API. These options may disable or override the defaults.


Methods

Name Description
to_string Returns a string representation of this construct.

to_string
def to_string() -> str

Returns a string representation of this construct.

Static Functions

Name Description
is_construct Checks if x is a construct.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSafeRestApi.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


Properties

Name Type Description
node constructs.Node The tree node.
api aws_cdk.aws_apigateway.SpecRestApi Underlying API Gateway API construct.
extended_api_specification typing.Any The OpenAPI specification with applied API gateway extensions.
ip_set aws_cdk.aws_wafv2.CfnIPSet Reference to the IP set if created.
web_acl aws_cdk.aws_wafv2.CfnWebACL Reference to the webacl, if created.
web_acl_association aws_cdk.aws_wafv2.CfnWebACLAssociation Reference to the web acl association if created.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


apiRequired
api: SpecRestApi
  • Type: aws_cdk.aws_apigateway.SpecRestApi

Underlying API Gateway API construct.


extended_api_specificationRequired
extended_api_specification: typing.Any
  • Type: typing.Any

The OpenAPI specification with applied API gateway extensions.


ip_setOptional
ip_set: CfnIPSet
  • Type: aws_cdk.aws_wafv2.CfnIPSet

Reference to the IP set if created.


web_aclOptional
web_acl: CfnWebACL
  • Type: aws_cdk.aws_wafv2.CfnWebACL

Reference to the webacl, if created.


web_acl_associationOptional
web_acl_association: CfnWebACLAssociation
  • Type: aws_cdk.aws_wafv2.CfnWebACLAssociation

Reference to the web acl association if created.


TypeSafeWebsocketApi

A construct for creating a websocket API, based on the provided spec and integrations.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSafeWebsocketApi(
  scope: Construct,
  id: str,
  api_key_selection_expression: WebSocketApiKeySelectionExpression = None,
  api_name: str = None,
  description: str = None,
  integrations: typing.Mapping[TypeSafeWebsocketApiIntegration],
  operation_lookup: typing.Mapping[WebsocketOperationDetails],
  spec_path: str,
  authorizer: IWebSocketRouteAuthorizer = None,
  connect: TypeSafeWebsocketApiIntegration = None,
  disable_access_logging: bool = None,
  disable_grant_management_access_to_lambdas: bool = None,
  disable_mock_integration_responses: bool = None,
  disconnect: TypeSafeWebsocketApiIntegration = None,
  stage_props: WebSocketStageProps = None
)
Name Type Description
scope constructs.Construct No description.
id str No description.
api_key_selection_expression aws_cdk.aws_apigatewayv2.WebSocketApiKeySelectionExpression An API key selection expression.
api_name str Name for the WebSocket API resource.
description str The description of the API.
integrations typing.Mapping[TypeSafeWebsocketApiIntegration] WebSocket routes and their corresponding integrations.
operation_lookup typing.Mapping[WebsocketOperationDetails] Details about each operation.
spec_path str Path to the websocket api specification json file.
authorizer aws_cdk.aws_apigatewayv2.IWebSocketRouteAuthorizer Authorizer to use for the API (applied to the $connect route).
connect TypeSafeWebsocketApiIntegration Integration for the $connect route (invoked when a new client connects).
disable_access_logging bool Disable access logging.
disable_grant_management_access_to_lambdas bool By default, all lambda integrations are granted management API access for the websocket API to send messages, disconnect clients, etc.
disable_mock_integration_responses bool By default, all mock integrations will automatically be configured with integration responses such that the integration is considered successful.
disconnect TypeSafeWebsocketApiIntegration Integration for the $disconnect route (invoked when a client disconnects).
stage_props WebSocketStageProps Options for the default stage.

scopeRequired
  • Type: constructs.Construct

idRequired
  • Type: str

api_key_selection_expressionOptional
  • Type: aws_cdk.aws_apigatewayv2.WebSocketApiKeySelectionExpression
  • Default: Key is not required to access these APIs

An API key selection expression.

Providing this option will require an API Key be provided to access the API.


api_nameOptional
  • Type: str
  • Default: id of the WebSocketApi construct.

Name for the WebSocket API resource.


descriptionOptional
  • Type: str
  • Default: none

The description of the API.


integrationsRequired

WebSocket routes and their corresponding integrations.


operation_lookupRequired

Details about each operation.


spec_pathRequired
  • Type: str

Path to the websocket api specification json file.


authorizerOptional
  • Type: aws_cdk.aws_apigatewayv2.IWebSocketRouteAuthorizer
  • Default: NONE

Authorizer to use for the API (applied to the $connect route).


connectOptional

Integration for the $connect route (invoked when a new client connects).


disable_access_loggingOptional
  • Type: bool
  • Default: false

Disable access logging.


disable_grant_management_access_to_lambdasOptional
  • Type: bool
  • Default: false

By default, all lambda integrations are granted management API access for the websocket API to send messages, disconnect clients, etc.

Set to true if you would like to manage these permissions manually.


disable_mock_integration_responsesOptional
  • Type: bool
  • Default: false

By default, all mock integrations will automatically be configured with integration responses such that the integration is considered successful.

Set to true to disable this (mock integrations will respond with errors)


disconnectOptional

Integration for the $disconnect route (invoked when a client disconnects).


stage_propsOptional

Options for the default stage.


Methods

Name Description
to_string Returns a string representation of this construct.

to_string
def to_string() -> str

Returns a string representation of this construct.

Static Functions

Name Description
is_construct Checks if x is a construct.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSafeWebsocketApi.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


Properties

Name Type Description
node constructs.Node The tree node.
api aws_cdk.aws_apigatewayv2.WebSocketApi Reference to the websocket API.
default_stage aws_cdk.aws_apigatewayv2.WebSocketStage Reference to the default deploy stage.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


apiRequired
api: WebSocketApi
  • Type: aws_cdk.aws_apigatewayv2.WebSocketApi

Reference to the websocket API.


default_stageRequired
default_stage: WebSocketStage
  • Type: aws_cdk.aws_apigatewayv2.WebSocketStage

Reference to the default deploy stage.


TypeSafeWebSocketApiProject

Project for a Type Safe WebSocket API, defined using Smithy or OpenAPI.

Generates a CDK construct to deploy your API, as well as client and server code to help build your API quickly.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSafeWebSocketApiProject(
  name: str,
  commit_generated: bool = None,
  git_ignore_options: IgnoreFileOptions = None,
  git_options: GitOptions = None,
  logging: LoggerOptions = None,
  outdir: str = None,
  parent: Project = None,
  projen_command: str = None,
  projenrc_json: bool = None,
  projenrc_json_options: ProjenrcJsonOptions = None,
  renovatebot: bool = None,
  renovatebot_options: RenovatebotOptions = None,
  infrastructure: WebSocketInfrastructureConfiguration,
  model: TypeSafeWebSocketApiModelConfiguration,
  documentation: WebSocketDocumentationConfiguration = None,
  handlers: WebSocketHandlersConfiguration = None,
  library: WebSocketLibraryConfiguration = None,
  runtime: WebSocketRuntimeConfiguration = None
)
Name Type Description
name str This is the name of your project.
commit_generated bool Whether to commit the managed files by default.
git_ignore_options projen.IgnoreFileOptions Configuration options for .gitignore file.
git_options projen.GitOptions Configuration options for git.
logging projen.LoggerOptions Configure logging options such as verbosity.
outdir str The root directory of the project.
parent projen.Project The parent project, if this project is part of a bigger project.
projen_command str The shell command to use in order to run the projen CLI.
projenrc_json bool Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.
projenrc_json_options projen.ProjenrcJsonOptions Options for .projenrc.json.
renovatebot bool Use renovatebot to handle dependency upgrades.
renovatebot_options projen.RenovatebotOptions Options for renovatebot.
infrastructure WebSocketInfrastructureConfiguration Configuration for generated infrastructure.
model TypeSafeWebSocketApiModelConfiguration Configuration for the API model.
documentation WebSocketDocumentationConfiguration Configuration for generated documentation.
handlers WebSocketHandlersConfiguration Configuration for lambda handlers for implementing the API.
library WebSocketLibraryConfiguration Configuration for generated libraries.
runtime WebSocketRuntimeConfiguration Configuration for generated runtime projects (containing types, clients and server code).

nameRequired
  • Type: str
  • Default: $BASEDIR

This is the name of your project.


commit_generatedOptional
  • Type: bool
  • Default: true

Whether to commit the managed files by default.


git_ignore_optionsOptional
  • Type: projen.IgnoreFileOptions

Configuration options for .gitignore file.


git_optionsOptional
  • Type: projen.GitOptions

Configuration options for git.


loggingOptional
  • Type: projen.LoggerOptions
  • Default: {}

Configure logging options such as verbosity.


outdirOptional
  • Type: str
  • Default: "."

The root directory of the project.

Relative to this directory, all files are synthesized.

If this project has a parent, this directory is relative to the parent directory and it cannot be the same as the parent or any of it's other subprojects.


parentOptional
  • Type: projen.Project

The parent project, if this project is part of a bigger project.


projen_commandOptional
  • Type: str
  • Default: "npx projen"

The shell command to use in order to run the projen CLI.

Can be used to customize in special environments.


projenrc_jsonOptional
  • Type: bool
  • Default: false

Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.


projenrc_json_optionsOptional
  • Type: projen.ProjenrcJsonOptions
  • Default: default options

Options for .projenrc.json.


renovatebotOptional
  • Type: bool
  • Default: false

Use renovatebot to handle dependency upgrades.


renovatebot_optionsOptional
  • Type: projen.RenovatebotOptions
  • Default: default options

Options for renovatebot.


infrastructureRequired

Configuration for generated infrastructure.


modelRequired

Configuration for the API model.


documentationOptional

Configuration for generated documentation.


handlersOptional

Configuration for lambda handlers for implementing the API.


libraryOptional

Configuration for generated libraries.

These include clients for interacting with your websocket API


runtimeOptional

Configuration for generated runtime projects (containing types, clients and server code).


Methods

Name Description
to_string Returns a string representation of this construct.
add_exclude_from_cleanup Exclude the matching files from pre-synth cleanup.
add_git_ignore Adds a .gitignore pattern.
add_package_ignore Exclude these files from the bundled package.
add_task Adds a new task to this project.
add_tip Prints a "tip" message during synthesis.
annotate_generated Consider a set of files as "generated".
post_synthesize Called after all components are synthesized.
pre_synthesize Called before all components are synthesized.
remove_task Removes a task from a project.
run_task_command Returns the shell command to execute in order to run a task.
synth Synthesize all project files into outdir.
try_find_file Finds a file at the specified relative path within this project and all its subprojects.
try_find_json_file Finds a json file by name.
try_find_object_file Finds an object file (like JsonFile, YamlFile, etc.) by name.
try_remove_file Finds a file at the specified relative path within this project and removes it.

to_string
def to_string() -> str

Returns a string representation of this construct.

add_exclude_from_cleanup
def add_exclude_from_cleanup(
  globs: str
) -> None

Exclude the matching files from pre-synth cleanup.

Can be used when, for example, some source files include the projen marker and we don't want them to be erased during synth.

globsRequired
  • Type: str

The glob patterns to match.


add_git_ignore
def add_git_ignore(
  pattern: str
) -> None

Adds a .gitignore pattern.

patternRequired
  • Type: str

The glob pattern to ignore.


add_package_ignore
def add_package_ignore(
  _pattern: str
) -> None

Exclude these files from the bundled package.

Implemented by project types based on the packaging mechanism. For example, NodeProject delegates this to .npmignore.

_patternRequired
  • Type: str

The glob pattern to exclude.


add_task
def add_task(
  name: str,
  condition: str = None,
  cwd: str = None,
  description: str = None,
  env: typing.Mapping[str] = None,
  required_env: typing.List[str] = None,
  args: typing.List[str] = None,
  exec: str = None,
  receive_args: bool = None,
  steps: typing.List[TaskStep] = None
) -> Task

Adds a new task to this project.

This will fail if the project already has a task with this name.

nameRequired
  • Type: str

The task name to add.


conditionOptional
  • Type: str

A shell command which determines if the this task should be executed.

If the program exits with a zero exit code, steps will be executed. A non-zero code means that task will be skipped.


cwdOptional
  • Type: str
  • Default: process.cwd()

The working directory for all steps in this task (unless overridden by the step).


descriptionOptional
  • Type: str
  • Default: the task name

The description of this build command.


envOptional
  • Type: typing.Mapping[str]
  • Default: {}

Defines environment variables for the execution of this task.

Values in this map will be evaluated in a shell, so you can do stuff like $(echo "foo").


required_envOptional
  • Type: typing.List[str]

A set of environment variables that must be defined in order to execute this task.

Task execution will fail if one of these is not defined.


argsOptional
  • Type: typing.List[str]
  • Default: no arguments are passed to the step

Should the provided exec shell command receive fixed args.

{@link TaskStepOptions.args }


execOptional
  • Type: str
  • Default: add steps using task.exec(command) or task.spawn(subtask)

Shell command to execute as the first command of the task.


receive_argsOptional
  • Type: bool
  • Default: false

Should the provided exec shell command receive args passed to the task.

{@link TaskStepOptions.receiveArgs }


stepsOptional
  • Type: typing.List[projen.TaskStep]

List of task steps to run.


~~add_tip~~
def add_tip(
  message: str
) -> None

Prints a "tip" message during synthesis.

messageRequired
  • Type: str

The message.


annotate_generated
def annotate_generated(
  _glob: str
) -> None

Consider a set of files as "generated".

This method is implemented by derived classes and used for example, to add git attributes to tell GitHub that certain files are generated.

_globRequired
  • Type: str

the glob pattern to match (could be a file path).


post_synthesize
def post_synthesize() -> None

Called after all components are synthesized.

Order is not guaranteed.

pre_synthesize
def pre_synthesize() -> None

Called before all components are synthesized.

remove_task
def remove_task(
  name: str
) -> Task

Removes a task from a project.

nameRequired
  • Type: str

The name of the task to remove.


run_task_command
def run_task_command(
  task: Task
) -> str

Returns the shell command to execute in order to run a task.

By default, this is npx projen@<version> <task>

taskRequired
  • Type: projen.Task

The task for which the command is required.


synth
def synth() -> None

Synthesize all project files into outdir.

  1. Call "this.preSynthesize()"
  2. Delete all generated files
  3. Synthesize all subprojects
  4. Synthesize all components of this project
  5. Call "postSynthesize()" for all components of this project
  6. Call "this.postSynthesize()"
try_find_file
def try_find_file(
  file_path: str
) -> FileBase

Finds a file at the specified relative path within this project and all its subprojects.

file_pathRequired
  • Type: str

The file path.

If this path is relative, it will be resolved from the root of this project.


~~try_find_json_file~~
def try_find_json_file(
  file_path: str
) -> JsonFile

Finds a json file by name.

file_pathRequired
  • Type: str

The file path.


try_find_object_file
def try_find_object_file(
  file_path: str
) -> ObjectFile

Finds an object file (like JsonFile, YamlFile, etc.) by name.

file_pathRequired
  • Type: str

The file path.


try_remove_file
def try_remove_file(
  file_path: str
) -> FileBase

Finds a file at the specified relative path within this project and removes it.

file_pathRequired
  • Type: str

The file path.

If this path is relative, it will be resolved from the root of this project.


Static Functions

Name Description
is_construct Checks if x is a construct.
is_project Test whether the given construct is a project.
of Find the closest ancestor project for given construct.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSafeWebSocketApiProject.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


is_project
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSafeWebSocketApiProject.is_project(
  x: typing.Any
)

Test whether the given construct is a project.

xRequired
  • Type: typing.Any

of
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSafeWebSocketApiProject.of(
  construct: IConstruct
)

Find the closest ancestor project for given construct.

When given a project, this it the project itself.

constructRequired
  • Type: constructs.IConstruct

Properties

Name Type Description
node constructs.Node The tree node.
build_task projen.Task No description.
commit_generated bool Whether to commit the managed files by default.
compile_task projen.Task No description.
components typing.List[projen.Component] Returns all the components within this project.
deps projen.Dependencies Project dependencies.
ejected bool Whether or not the project is being ejected.
files typing.List[projen.FileBase] All files in this project.
gitattributes projen.GitAttributesFile The .gitattributes file for this repository.
gitignore projen.IgnoreFile .gitignore.
logger projen.Logger Logging utilities.
name str Project name.
outdir str Absolute output directory of this project.
package_task projen.Task No description.
post_compile_task projen.Task No description.
pre_compile_task projen.Task No description.
project_build projen.ProjectBuild Manages the build process of the project.
projen_command str The command to use in order to run the projen CLI.
root projen.Project The root project.
subprojects typing.List[projen.Project] Returns all the subprojects within this project.
tasks projen.Tasks Project tasks.
test_task projen.Task No description.
default_task projen.Task This is the "default" task, the one that executes "projen".
init_project projen.InitProject The options used when this project is bootstrapped via projen new.
parent projen.Project A parent project.
all ProjectCollections Collections of all sub-projects managed by this project.
documentation GeneratedWebSocketDocumentationProjects Generated documentation projects.
handlers GeneratedCodeProjects Lambda handlers projects.
infrastructure GeneratedCodeProjects Generated infrastructure projects.
library GeneratedWebSocketLibraryProjects Generated library projects.
model WebSocketModelProject Project for the api model.
runtime GeneratedCodeProjects Generated runtime projects.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


build_taskRequired
build_task: Task
  • Type: projen.Task

commit_generatedRequired
commit_generated: bool
  • Type: bool

Whether to commit the managed files by default.


compile_taskRequired
compile_task: Task
  • Type: projen.Task

componentsRequired
components: typing.List[Component]
  • Type: typing.List[projen.Component]

Returns all the components within this project.


depsRequired
deps: Dependencies
  • Type: projen.Dependencies

Project dependencies.


ejectedRequired
ejected: bool
  • Type: bool

Whether or not the project is being ejected.


filesRequired
files: typing.List[FileBase]
  • Type: typing.List[projen.FileBase]

All files in this project.


gitattributesRequired
gitattributes: GitAttributesFile
  • Type: projen.GitAttributesFile

The .gitattributes file for this repository.


gitignoreRequired
gitignore: IgnoreFile
  • Type: projen.IgnoreFile

.gitignore.


loggerRequired
logger: Logger
  • Type: projen.Logger

Logging utilities.


nameRequired
name: str
  • Type: str

Project name.


outdirRequired
outdir: str
  • Type: str

Absolute output directory of this project.


package_taskRequired
package_task: Task
  • Type: projen.Task

post_compile_taskRequired
post_compile_task: Task
  • Type: projen.Task

pre_compile_taskRequired
pre_compile_task: Task
  • Type: projen.Task

project_buildRequired
project_build: ProjectBuild
  • Type: projen.ProjectBuild

Manages the build process of the project.


projen_commandRequired
projen_command: str
  • Type: str

The command to use in order to run the projen CLI.


rootRequired
root: Project
  • Type: projen.Project

The root project.


subprojectsRequired
subprojects: typing.List[Project]
  • Type: typing.List[projen.Project]

Returns all the subprojects within this project.


tasksRequired
tasks: Tasks
  • Type: projen.Tasks

Project tasks.


test_taskRequired
test_task: Task
  • Type: projen.Task

default_taskOptional
default_task: Task
  • Type: projen.Task

This is the "default" task, the one that executes "projen".

Undefined if the project is being ejected.


init_projectOptional
init_project: InitProject
  • Type: projen.InitProject

The options used when this project is bootstrapped via projen new.

It includes the original set of options passed to the CLI and also the JSII FQN of the project type.


parentOptional
parent: Project
  • Type: projen.Project

A parent project.

If undefined, this is the root project.


allRequired
all: ProjectCollections

Collections of all sub-projects managed by this project.


documentationRequired
documentation: GeneratedWebSocketDocumentationProjects

Generated documentation projects.

Only the properties corresponding to specified documentation.formats will be defined.


handlersRequired
handlers: GeneratedCodeProjects

Lambda handlers projects.

Only the properties corresponding to handlers.languages will be defined.


infrastructureRequired
infrastructure: GeneratedCodeProjects

Generated infrastructure projects.

Only the property corresponding to infrastructure.language will be defined.


libraryRequired
library: GeneratedWebSocketLibraryProjects

Generated library projects.

Only the properties corresponding to specified library.libraries will be defined.


modelRequired
model: WebSocketModelProject

Project for the api model.


runtimeRequired
runtime: GeneratedCodeProjects

Generated runtime projects.

When runtime.languages includes the corresponding language, the project can be assumed to be defined.


Constants

Name Type Description
DEFAULT_TASK str The name of the default task (the task executed when projen is run without arguments).

DEFAULT_TASKRequired
DEFAULT_TASK: str
  • Type: str

The name of the default task (the task executed when projen is run without arguments).

Normally this task should synthesize the project files.


TypeSpecAsyncDefinition

The TypeSpec model definition for an async api.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSpecAsyncDefinition(
  project: NodeProject,
  type_spec_options: TypeSpecModelOptions,
  handler_languages: typing.List[Language] = None
)
Name Type Description
project projen.javascript.NodeProject No description.
type_spec_options TypeSpecModelOptions TypeSpec model options.
handler_languages typing.List[Language] The languages users have specified for handler projects (if any).

projectRequired
  • Type: projen.javascript.NodeProject

type_spec_optionsRequired

TypeSpec model options.


handler_languagesOptional

The languages users have specified for handler projects (if any).


Methods

Name Description
to_string Returns a string representation of this construct.
post_synthesize Called after synthesis.
pre_synthesize Called before synthesis.
synthesize Synthesizes files to the project output directory.

to_string
def to_string() -> str

Returns a string representation of this construct.

post_synthesize
def post_synthesize() -> None

Called after synthesis.

Order is not guaranteed.

pre_synthesize
def pre_synthesize() -> None

Called before synthesis.

synthesize
def synthesize() -> None

Synthesizes files to the project output directory.

Static Functions

Name Description
is_construct Checks if x is a construct.
is_component Test whether the given construct is a component.

is_construct
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSpecAsyncDefinition.is_construct(
  x: typing.Any
)

Checks if x is a construct.

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

xRequired
  • Type: typing.Any

Any object.


is_component
import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSpecAsyncDefinition.is_component(
  x: typing.Any
)

Test whether the given construct is a component.

xRequired
  • Type: typing.Any

Properties

Name Type Description
node constructs.Node The tree node.
project projen.Project No description.
open_api_specification_path str Path to the generated OpenAPI specification.

nodeRequired
node: Node
  • Type: constructs.Node

The tree node.


projectRequired
project: Project
  • Type: projen.Project

open_api_specification_pathRequired
open_api_specification_path: str
  • Type: str

Path to the generated OpenAPI specification.


TypeSpecAsyncModelProject

Model project for defining a WebSocket API in TypeSpec.

Initializers

import aws.pdk.type_safe_api

aws.pdk.type_safe_api.TypeSpecAsyncModelProject(
  name: str,
  commit_generated: bool = None,
  git_ignore_options: IgnoreFileOptions = None,
  git_options: GitOptions = None,
  logging: LoggerOptions = None,
  outdir: str = None,
  parent: Project = None,
  projen_command: str = None,
  projenrc_json: bool = None,
  projenrc_json_options: ProjenrcJsonOptions = None,
  renovatebot: bool = None,
  renovatebot_options: RenovatebotOptions = None,
  auto_approve_options: AutoApproveOptions = None,
  auto_merge: bool = None,
  auto_merge_options: AutoMergeOptions = None,
  clobber: bool = None,
  dev_container: bool = None,
  github: bool = None,
  github_options: GitHubOptions = None,
  gitpod: bool = None,
  mergify: bool = None,
  mergify_options: MergifyOptions = None,
  project_type: ProjectType = None,
  projen_credentials: GithubCredentials = None,
  projen_token_secret: str = None,
  readme: SampleReadmeProps = None,
  stale: bool = None,
  stale_options: StaleOptions = None,
  vscode: bool = None,
  allow_library_dependencies: bool = None,
  author_email: str = None,
  author_name: str = None,
  author_organization: bool = None,
  author_url: str = None,
  auto_detect_bin: bool = None,
  bin: typing.Mapping[str] = None,
  bugs_email: str = None,
  bugs_url: str = None,
  bundled_deps: typing.List[str] = None,
  code_artifact_options: CodeArtifactOptions = None,
  deps: typing.List[str] = None,
  description: str = None,
  dev_deps: typing.List[str] = None,
  entrypoint: str = None,
  homepage: str = None,
  keywords: typing.List[str] = None,
  license: str = None,
  licensed: bool = None,
  max_node_version: str = None,
  min_node_version: str = None,
  npm_access: NpmAccess = None,
  npm_provenance: bool = None,
  npm_registry: str = None,
  npm_registry_url: str = None,
  npm_token_secret: str = None,
  package_manager: NodePackageManager = None,
  package_name: str = None,
  peer_dependency_options: PeerDependencyOptions = None,
  peer_deps: typing.List[str] = None,
  pnpm_version: str = None,
  repository: str = None,
  repository_directory: str = None,
  scoped_packages_options: typing.List[ScopedPackagesOptions] = None,
  scripts: typing.Mapping[str] = None,
  stability: str = None,
  yarn_berry_options: YarnBerryOptions = None,
  jsii_release_version: str = None,
  major_version: typing.Union[int, float] = None,
  min_major_version: typing.Union[int, float] = None,
  npm_dist_tag: str = None,
  post_build_steps: typing.List[JobStep] = None,
  prerelease: str = None,
  publish_dry_run: bool = None,
  publish_tasks: bool = None,
  releasable_commits: ReleasableCommits = None,
  release_branches: typing.Mapping[BranchOptions] = None,
  release_every_commit: bool = None,
  release_failure_issue: bool = None,
  release_failure_issue_label: str = None,
  release_schedule: str = None,
  release_tag_prefix: str = None,
  release_trigger: ReleaseTrigger = None,
  release_workflow_name: str = None,
  release_workflow_setup_steps: typing.List[JobStep] = None,
  versionrc_options: typing.Mapping[typing.Any] = None,
  workflow_container_image: str = None,
  workflow_runs_on: typing.List[str] = None,
  workflow_runs_on_group: GroupRunnerOptions = None,
  default_release_branch: str,
  artifacts_directory: str = None,
  auto_approve_upgrades: bool = None,
  build_workflow: bool = None,
  build_workflow_options: BuildWorkflowOptions = None,
  build_workflow_triggers: Triggers = None,
  bundler_options: BundlerOptions = None,
  check_licenses: LicenseCheckerOptions = None,
  code_cov: bool = None,
  code_cov_token_secret: str = None,
  copyright_owner: str = None,
  copyright_period: str = None,
  dependabot: bool = None,
  dependabot_options: DependabotOptions = None,
  deps_upgrade: bool = None,
  deps_upgrade_options: UpgradeDependenciesOptions = None,
  gitignore: typing.List[str] = None,
  jest: bool = None,
  jest_options: JestOptions = None,
  mutable_build: bool = None,
  npmignore: typing.List[str] = None,
  npmignore_enabled: bool = None,
  npm_ignore_options: IgnoreFileOptions = None,
  package: bool = None,
  prettier: bool = None,
  prettier_options: PrettierOptions = None,
  projen_dev_dependency: bool = None,
  projenrc_js: bool = None,
  projenrc_js_options: ProjenrcOptions = None,
  projen_version: str = None,
  pull_request_template: bool = None,
  pull_request_template_contents: typing.List[str] = None,
  release: bool = None,
  release_to_npm: bool = None,
  release_workflow: bool = None,
  workflow_bootstrap_steps: typing.List[JobStep] = None,
  workflow_git_identity: GitIdentity = None,
  workflow_node_version: str = None,
  workflow_package_cache: bool = None,
  type_spec_options: TypeSpecModelOptions,
  handler_languages: typing.List[Language] = None,
  async_api_spec_file: str,
  parsed_spec_file: str
)
Name Type Description
name str This is the name of your project.
commit_generated bool Whether to commit the managed files by default.
git_ignore_options projen.IgnoreFileOptions Configuration options for .gitignore file.
git_options projen.GitOptions Configuration options for git.
logging projen.LoggerOptions Configure logging options such as verbosity.
outdir str The root directory of the project.
parent projen.Project The parent project, if this project is part of a bigger project.
projen_command str The shell command to use in order to run the projen CLI.
projenrc_json bool Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.
projenrc_json_options projen.ProjenrcJsonOptions Options for .projenrc.json.
renovatebot bool Use renovatebot to handle dependency upgrades.
renovatebot_options projen.RenovatebotOptions Options for renovatebot.
auto_approve_options projen.github.AutoApproveOptions Enable and configure the 'auto approve' workflow.
auto_merge bool Enable automatic merging on GitHub.
auto_merge_options projen.github.AutoMergeOptions Configure options for automatic merging on GitHub.
clobber bool Add a clobber task which resets the repo to origin.
dev_container bool Add a VSCode development environment (used for GitHub Codespaces).
github bool Enable GitHub integration.
github_options projen.github.GitHubOptions Options for GitHub integration.
gitpod bool Add a Gitpod development environment.
mergify bool Whether mergify should be enabled on this repository or not.
mergify_options projen.github.MergifyOptions Options for mergify.
project_type projen.ProjectType Which type of project this is (library/app).
projen_credentials projen.github.GithubCredentials Choose a method of providing GitHub API access for projen workflows.
projen_token_secret str The name of a secret which includes a GitHub Personal Access Token to be used by projen workflows.
readme projen.SampleReadmeProps The README setup.
stale bool Auto-close of stale issues and pull request.
stale_options projen.github.StaleOptions Auto-close stale issues and pull requests.
vscode bool Enable VSCode integration.
allow_library_dependencies bool Allow the project to include peerDependencies and bundledDependencies.
author_email str Author's e-mail.
author_name str Author's name.
author_organization bool Is the author an organization.
author_url str Author's URL / Website.
auto_detect_bin bool Automatically add all executables under the bin directory to your package.json file under the bin section.
bin typing.Mapping[str] Binary programs vended with your module.
bugs_email str The email address to which issues should be reported.
bugs_url str The url to your project's issue tracker.
bundled_deps typing.List[str] List of dependencies to bundle into this module.
code_artifact_options projen.javascript.CodeArtifactOptions Options for npm packages using AWS CodeArtifact.
deps typing.List[str] Runtime dependencies of this module.
description str The description is just a string that helps people understand the purpose of the package.
dev_deps typing.List[str] Build dependencies for this module.
entrypoint str Module entrypoint (main in package.json).
homepage str Package's Homepage / Website.
keywords typing.List[str] Keywords to include in package.json.
license str License's SPDX identifier.
licensed bool Indicates if a license should be added.
max_node_version str Minimum node.js version to require via engines (inclusive).
min_node_version str Minimum Node.js version to require via package.json engines (inclusive).
npm_access projen.javascript.NpmAccess Access level of the npm package.
npm_provenance bool Should provenance statements be generated when the package is published.
npm_registry str The host name of the npm registry to publish to.
npm_registry_url str The base URL of the npm package registry.
npm_token_secret str GitHub secret which contains the NPM token to use when publishing packages.
package_manager projen.javascript.NodePackageManager The Node Package Manager used to execute scripts.
package_name str The "name" in package.json.
peer_dependency_options projen.javascript.PeerDependencyOptions Options for peerDeps.
peer_deps typing.List[str] Peer dependencies for this module.
pnpm_version str The version of PNPM to use if using PNPM as a package manager.
repository str The repository is the location where the actual code for your package lives.
repository_directory str If the package.json for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives.
scoped_packages_options typing.List[projen.javascript.ScopedPackagesOptions] Options for privately hosted scoped packages.
scripts typing.Mapping[str] npm scripts to include.
stability str Package's Stability.
yarn_berry_options projen.javascript.YarnBerryOptions Options for Yarn Berry.
jsii_release_version str Version requirement of publib which is used to publish modules to npm.
major_version typing.Union[int, float] Major version to release from the default branch.
min_major_version typing.Union[int, float] Minimal Major version to release.
npm_dist_tag str The npmDistTag to use when publishing from the default branch.
post_build_steps typing.List[projen.github.workflows.JobStep] Steps to execute after build as part of the release workflow.
prerelease str Bump versions from the default branch as pre-releases (e.g. "beta", "alpha", "pre").
publish_dry_run bool Instead of actually publishing to package managers, just print the publishing command.
publish_tasks bool Define publishing tasks that can be executed manually as well as workflows.
releasable_commits projen.ReleasableCommits Find commits that should be considered releasable Used to decide if a release is required.
release_branches typing.Mapping[projen.release.BranchOptions] Defines additional release branches.
release_every_commit bool Automatically release new versions every commit to one of branches in releaseBranches.
release_failure_issue bool Create a github issue on every failed publishing task.
release_failure_issue_label str The label to apply to issues indicating publish failures.
release_schedule str CRON schedule to trigger new releases.
release_tag_prefix str Automatically add the given prefix to release tags. Useful if you are releasing on multiple branches with overlapping version numbers.
release_trigger projen.release.ReleaseTrigger The release trigger to use.
release_workflow_name str The name of the default release workflow.
release_workflow_setup_steps typing.List[projen.github.workflows.JobStep] A set of workflow steps to execute in order to setup the workflow container.
versionrc_options typing.Mapping[typing.Any] Custom configuration used when creating changelog with standard-version package.
workflow_container_image str Container image to use for GitHub workflows.
workflow_runs_on typing.List[str] Github Runner selection labels.
workflow_runs_on_group projen.GroupRunnerOptions Github Runner Group selection options.
default_release_branch str The name of the main release branch.
artifacts_directory str A directory which will contain build artifacts.
auto_approve_upgrades bool Automatically approve deps upgrade PRs, allowing them to be merged by mergify (if configued).
build_workflow bool Define a GitHub workflow for building PRs.
build_workflow_options projen.javascript.BuildWorkflowOptions Options for PR build workflow.
build_workflow_triggers projen.github.workflows.Triggers Build workflow triggers.
bundler_options projen.javascript.BundlerOptions Options for Bundler.
check_licenses projen.javascript.LicenseCheckerOptions Configure which licenses should be deemed acceptable for use by dependencies.
code_cov bool Define a GitHub workflow step for sending code coverage metrics to https://codecov.io/ Uses codecov/codecov-action@v4 A secret is required for private repos. Configured with @codeCovTokenSecret.
code_cov_token_secret str Define the secret name for a specified https://codecov.io/ token A secret is required to send coverage for private repositories.
copyright_owner str License copyright owner.
copyright_period str The copyright years to put in the LICENSE file.
dependabot bool Use dependabot to handle dependency upgrades.
dependabot_options projen.github.DependabotOptions Options for dependabot.
deps_upgrade bool Use tasks and github workflows to handle dependency upgrades.
deps_upgrade_options projen.javascript.UpgradeDependenciesOptions Options for UpgradeDependencies.
gitignore typing.List[str] Additional entries to .gitignore.
jest bool Setup jest unit tests.
jest_options projen.javascript.JestOptions Jest options.
mutable_build bool Automatically update files modified during builds to pull-request branches.
npmignore typing.List[str] Additional entries to .npmignore.
npmignore_enabled bool Defines an .npmignore file. Normally this is only needed for libraries that are packaged as tarballs.
npm_ignore_options projen.IgnoreFileOptions Configuration options for .npmignore file.
package bool Defines a package task that will produce an npm tarball under the artifacts directory (e.g. dist).
prettier bool Setup prettier.
prettier_options projen.javascript.PrettierOptions Prettier options.
projen_dev_dependency bool Indicates of "projen" should be installed as a devDependency.
projenrc_js bool Generate (once) .projenrc.js (in JavaScript). Set to false in order to disable .projenrc.js generation.
projenrc_js_options projen.javascript.ProjenrcOptions Options for .projenrc.js.
projen_version str Version of projen to install.
pull_request_template bool Include a GitHub pull request template.
pull_request_template_contents typing.List[str] The contents of the pull request template.
release bool Add release management to this project.
release_to_npm bool Automatically release to npm when new versions are introduced.
release_workflow bool DEPRECATED: renamed to release.
workflow_bootstrap_steps typing.List[projen.github.workflows.JobStep] Workflow steps to use in order to bootstrap this repo.
workflow_git_identity projen.github.GitIdentity The git identity to use in workflows.
workflow_node_version str The node version to use in GitHub workflows.
workflow_package_cache bool Enable Node.js package cache in GitHub workflows.
type_spec_options TypeSpecModelOptions TypeSpec model options.
handler_languages typing.List[Language] The languages users have specified for handler projects (if any).
async_api_spec_file str Path to the generated AsyncAPI specification (relative to the project root).
parsed_spec_file str Path of the parsed/bundled OpenAPI specification (relative to the project root).

nameRequired
  • Type: str
  • Default: $BASEDIR

This is the name of your project.


commit_generatedOptional
  • Type: bool
  • Default: true

Whether to commit the managed files by default.


git_ignore_optionsOptional
  • Type: projen.IgnoreFileOptions

Configuration options for .gitignore file.


git_optionsOptional
  • Type: projen.GitOptions

Configuration options for git.


loggingOptional
  • Type: projen.LoggerOptions
  • Default: {}

Configure logging options such as verbosity.


outdirOptional
  • Type: str
  • Default: "."

The root directory of the project.

Relative to this directory, all files are synthesized.

If this project has a parent, this directory is relative to the parent directory and it cannot be the same as the parent or any of it's other subprojects.


parentOptional
  • Type: projen.Project

The parent project, if this project is part of a bigger project.


projen_commandOptional
  • Type: str
  • Default: "npx projen"

The shell command to use in order to run the projen CLI.

Can be used to customize in special environments.


projenrc_jsonOptional
  • Type: bool
  • Default: false

Generate (once) .projenrc.json (in JSON). Set to false in order to disable .projenrc.json generation.


projenrc_json_optionsOptional
  • Type: projen.ProjenrcJsonOptions
  • Default: default options

Options for .projenrc.json.


renovatebotOptional
  • Type: bool
  • Default: false

Use renovatebot to handle dependency upgrades.


renovatebot_optionsOptional
  • Type: projen.RenovatebotOptions
  • Default: default options

Options for renovatebot.


auto_approve_optionsOptional
  • Type: projen.github.AutoApproveOptions
  • Default: auto approve is disabled

Enable and configure the 'auto approve' workflow.


auto_mergeOptional
  • Type: bool
  • Default: true

Enable automatic merging on GitHub.

Has no effect if github.mergify is set to false.


auto_merge_optionsOptional
  • Type: projen.github.AutoMergeOptions
  • Default: see defaults in AutoMergeOptions

Configure options for automatic merging on GitHub.

Has no effect if github.mergify or autoMerge is set to false.


clobberOptional
  • Type: bool
  • Default: true, but false for subprojects

Add a clobber task which resets the repo to origin.


dev_containerOptional
  • Type: bool
  • Default: false

Add a VSCode development environment (used for GitHub Codespaces).


githubOptional
  • Type: bool
  • Default: true

Enable GitHub integration.

Enabled by default for root projects. Disabled for non-root projects.


github_optionsOptional
  • Type: projen.github.GitHubOptions
  • Default: see GitHubOptions

Options for GitHub integration.


gitpodOptional
  • Type: bool
  • Default: false

Add a Gitpod development environment.


~~mergify~~Optional
  • Deprecated: use githubOptions.mergify instead

  • Type: bool

  • Default: true

Whether mergify should be enabled on this repository or not.


~~mergify_options~~Optional
  • Deprecated: use githubOptions.mergifyOptions instead

  • Type: projen.github.MergifyOptions

  • Default: default options

Options for mergify.


~~project_type~~Optional
  • Deprecated: no longer supported at the base project level

  • Type: projen.ProjectType

  • Default: ProjectType.UNKNOWN

Which type of project this is (library/app).


projen_credentialsOptional
  • Type: projen.github.GithubCredentials
  • Default: use a personal access token named PROJEN_GITHUB_TOKEN

Choose a method of providing GitHub API access for projen workflows.


~~projen_token_secret~~Optional
  • Deprecated: use projenCredentials

  • Type: str

  • Default: "PROJEN_GITHUB_TOKEN"

The name of a secret which includes a GitHub Personal Access Token to be used by projen workflows.

This token needs to have the repo, workflows and packages scope.


readmeOptional
  • Type: projen.SampleReadmeProps
  • Default: { filename: 'README.md', contents: '# replace this' }

The README setup.


Example

"{ filename: 'readme.md', contents: '# title' }"
staleOptional
  • Type: bool
  • Default: false

Auto-close of stale issues and pull request.

See staleOptions for options.


stale_optionsOptional
  • Type: projen.github.StaleOptions
  • Default: see defaults in StaleOptions

Auto-close stale issues and pull requests.

To disable set stale to false.


vscodeOptional
  • Type: bool
  • Default: true

Enable VSCode integration.

Enabled by default for root projects. Disabled for non-root projects.


allow_library_dependenciesOptional
  • Type: bool
  • Default: true

Allow the project to include peerDependencies and bundledDependencies.

This is normally only allowed for libraries. For apps, there's no meaning for specifying these.


author_emailOptional
  • Type: str

Author's e-mail.


author_nameOptional
  • Type: str

Author's name.


author_organizationOptional
  • Type: bool

Is the author an organization.


author_urlOptional
  • Type: str

Author's URL / Website.


auto_detect_binOptional
  • Type: bool
  • Default: true

Automatically add all executables under the bin directory to your package.json file under the bin section.


binOptional
  • Type: typing.Mapping[str]

Binary programs vended with your module.

You can use this option to add/customize how binaries are represented in your package.json, but unless autoDetectBin is false, every executable file under bin will automatically be added to this section.


bugs_emailOptional
  • Type: str

The email address to which issues should be reported.


bugs_urlOptional
  • Type: str

The url to your project's issue tracker.


bundled_depsOptional
  • Type: typing.List[str]

List of dependencies to bundle into this module.

These modules will be added both to the dependencies section and bundledDependencies section of your package.json.

The recommendation is to only specify the module name here (e.g. express). This will behave similar to yarn add or npm install in the sense that it will add the module as a dependency to your package.json file with the latest version (^). You can specify semver requirements in the same syntax passed to npm i or yarn add (e.g. express@^2) and this will be what you package.json will eventually include.


code_artifact_optionsOptional
  • Type: projen.javascript.CodeArtifactOptions
  • Default: undefined

Options for npm packages using AWS CodeArtifact.

This is required if publishing packages to, or installing scoped packages from AWS CodeArtifact


depsOptional
  • Type: typing.List[str]
  • Default: []

Runtime dependencies of this module.

The recommendation is to only specify the module name here (e.g. express). This will behave similar to yarn add or npm install in the sense that it will add the module as a dependency to your package.json file with the latest version (^). You can specify semver requirements in the same syntax passed to npm i or yarn add (e.g. express@^2) and this will be what you package.json will eventually include.


Example

[ 'express', 'lodash', 'foo@^2' ]
descriptionOptional
  • Type: str

The description is just a string that helps people understand the purpose of the package.

It can be used when searching for packages in a package manager as well. See https://classic.yarnpkg.com/en/docs/package-json/#toc-description


dev_depsOptional
  • Type: typing.List[str]
  • Default: []

Build dependencies for this module.

These dependencies will only be available in your build environment but will not be fetched when this module is consumed.

The recommendation is to only specify the module name here (e.g. express). This will behave similar to yarn add or npm install in the sense that it will add the module as a dependency to your package.json file with the latest version (^). You can specify semver requirements in the same syntax passed to npm i or yarn add (e.g. express@^2) and this will be what you package.json will eventually include.


Example

[ 'typescript', '@types/express' ]
entrypointOptional
  • Type: str
  • Default: "lib/index.js"

Module entrypoint (main in package.json).

Set to an empty string to not include main in your package.json


homepageOptional
  • Type: str

Package's Homepage / Website.


keywordsOptional
  • Type: typing.List[str]

Keywords to include in package.json.


licenseOptional
  • Type: str
  • Default: "Apache-2.0"

License's SPDX identifier.

See https://github.com/projen/projen/tree/main/license-text for a list of supported licenses. Use the licensed option if you want to no license to be specified.


licensedOptional
  • Type: bool
  • Default: true

Indicates if a license should be added.


max_node_versionOptional
  • Type: str
  • Default: no max

Minimum node.js version to require via engines (inclusive).


min_node_versionOptional
  • Type: str
  • Default: no "engines" specified

Minimum Node.js version to require via package.json engines (inclusive).


npm_accessOptional
  • Type: projen.javascript.NpmAccess
  • Default: for scoped packages (e.g. foo@bar), the default is NpmAccess.RESTRICTED, for non-scoped packages, the default is NpmAccess.PUBLIC.

Access level of the npm package.


npm_provenanceOptional
  • Type: bool
  • Default: true for public packages, false otherwise

Should provenance statements be generated when the package is published.

A supported package manager is required to publish a package with npm provenance statements and you will need to use a supported CI/CD provider.

Note that the projen Release and Publisher components are using publib to publish packages, which is using npm internally and supports provenance statements independently of the package manager used.

https://docs.npmjs.com/generating-provenance-statements


~~npm_registry~~Optional
  • Deprecated: use npmRegistryUrl instead

  • Type: str

The host name of the npm registry to publish to.

Cannot be set together with npmRegistryUrl.


npm_registry_urlOptional

The base URL of the npm package registry.

Must be a URL (e.g. start with "https://" or "http://")


npm_token_secretOptional
  • Type: str
  • Default: "NPM_TOKEN"

GitHub secret which contains the NPM token to use when publishing packages.


package_managerOptional
  • Type: projen.javascript.NodePackageManager
  • Default: NodePackageManager.YARN_CLASSIC

The Node Package Manager used to execute scripts.


package_nameOptional
  • Type: str
  • Default: defaults to project name

The "name" in package.json.


peer_dependency_optionsOptional
  • Type: projen.javascript.PeerDependencyOptions

Options for peerDeps.


peer_depsOptional
  • Type: typing.List[str]
  • Default: []

Peer dependencies for this module.

Dependencies listed here are required to be installed (and satisfied) by the consumer of this library. Using peer dependencies allows you to ensure that only a single module of a certain library exists in the node_modules tree of your consumers.

Note that prior to npm@7, peer dependencies are not automatically installed, which means that adding peer dependencies to a library will be a breaking change for your customers.

Unless peerDependencyOptions.pinnedDevDependency is disabled (it is enabled by default), projen will automatically add a dev dependency with a pinned version for each peer dependency. This will ensure that you build & test your module against the lowest peer version required.


pnpm_versionOptional
  • Type: str
  • Default: "7"

The version of PNPM to use if using PNPM as a package manager.


repositoryOptional
  • Type: str

The repository is the location where the actual code for your package lives.

See https://classic.yarnpkg.com/en/docs/package-json/#toc-repository


repository_directoryOptional
  • Type: str

If the package.json for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives.


scoped_packages_optionsOptional
  • Type: typing.List[projen.javascript.ScopedPackagesOptions]
  • Default: fetch all scoped packages from the public npm registry

Options for privately hosted scoped packages.


~~scripts~~Optional
  • Deprecated: use project.addTask() or package.setScript()

  • Type: typing.Mapping[str]

  • Default: {}

npm scripts to include.

If a script has the same name as a standard script, the standard script will be overwritten. Also adds the script as a task.


stabilityOptional
  • Type: str

Package's Stability.


yarn_berry_optionsOptional
  • Type: projen.javascript.YarnBerryOptions
  • Default: Yarn Berry v4 with all default options

Options for Yarn Berry.


jsii_release_versionOptional
  • Type: str
  • Default: "latest"

Version requirement of publib which is used to publish modules to npm.


major_versionOptional
  • Type: typing.Union[int, float]
  • Default: Major version is not enforced.

Major version to release from the default branch.

If this is specified, we bump the latest version of this major version line. If not specified, we bump the global latest version.


min_major_versionOptional
  • Type: typing.Union[int, float]
  • Default: No minimum version is being enforced

Minimal Major version to release.

This can be useful to set to 1, as breaking changes before the 1.x major release are not incrementing the major version number.

Can not be set together with majorVersion.


npm_dist_tagOptional
  • Type: str
  • Default: "latest"

The npmDistTag to use when publishing from the default branch.

To set the npm dist-tag for release branches, set the npmDistTag property for each branch.


post_build_stepsOptional
  • Type: typing.List[projen.github.workflows.JobStep]
  • Default: []

Steps to execute after build as part of the release workflow.


prereleaseOptional
  • Type: str
  • Default: normal semantic versions

Bump versions from the default branch as pre-releases (e.g. "beta", "alpha", "pre").


publish_dry_runOptional
  • Type: bool
  • Default: false

Instead of actually publishing to package managers, just print the publishing command.


publish_tasksOptional
  • Type: bool
  • Default: false

Define publishing tasks that can be executed manually as well as workflows.

Normally, publishing only happens within automated workflows. Enable this in order to create a publishing task for each publishing activity.


releasable_commitsOptional
  • Type: projen.ReleasableCommits
  • Default: ReleasableCommits.everyCommit()

Find commits that should be considered releasable Used to decide if a release is required.


release_branchesOptional
  • Type: typing.Mapping[projen.release.BranchOptions]
  • Default: no additional branches are used for release. you can use addBranch() to add additional branches.

Defines additional release branches.

A workflow will be created for each release branch which will publish releases from commits in this branch. Each release branch must be assigned a major version number which is used to enforce that versions published from that branch always use that major version. If multiple branches are used, the majorVersion field must also be provided for the default branch.


~~release_every_commit~~Optional
  • Deprecated: Use releaseTrigger: ReleaseTrigger.continuous() instead

  • Type: bool

  • Default: true

Automatically release new versions every commit to one of branches in releaseBranches.


release_failure_issueOptional
  • Type: bool
  • Default: false

Create a github issue on every failed publishing task.


release_failure_issue_labelOptional
  • Type: str
  • Default: "failed-release"

The label to apply to issues indicating publish failures.

Only applies if releaseFailureIssue is true.


~~release_schedule~~Optional
  • Deprecated: Use releaseTrigger: ReleaseTrigger.scheduled() instead

  • Type: str

  • Default: no scheduled releases

CRON schedule to trigger new releases.


release_tag_prefixOptional
  • Type: str
  • Default: "v"

Automatically add the given prefix to release tags. Useful if you are releasing on multiple branches with overlapping version numbers.

Note: this prefix is used to detect the latest tagged version when bumping, so if you change this on a project with an existing version history, you may need to manually tag your latest release with the new prefix.


release_triggerOptional
  • Type: projen.release.ReleaseTrigger
  • Default: Continuous releases (ReleaseTrigger.continuous())

The release trigger to use.


release_workflow_nameOptional
  • Type: str
  • Default: "release"

The name of the default release workflow.


release_workflow_setup_stepsOptional
  • Type: typing.List[projen.github.workflows.JobStep]

A set of workflow steps to execute in order to setup the workflow container.


versionrc_optionsOptional
  • Type: typing.Mapping[typing.Any]
  • Default: standard configuration applicable for GitHub repositories

Custom configuration used when creating changelog with standard-version package.

Given values either append to default configuration or overwrite values in it.


workflow_container_imageOptional
  • Type: str
  • Default: default image

Container image to use for GitHub workflows.


workflow_runs_onOptional
  • Type: typing.List[str]
  • Default: ["ubuntu-latest"]

Github Runner selection labels.


workflow_runs_on_groupOptional
  • Type: projen.GroupRunnerOptions

Github Runner Group selection options.


default_release_branchRequired
  • Type: str
  • Default: "main"

The name of the main release branch.


artifacts_directoryOptional
  • Type: str
  • Default: "dist"

A directory which will contain build artifacts.


auto_approve_upgradesOptional
  • Type: bool
  • Default: true

Automatically approve deps upgrade PRs, allowing them to be merged by mergify (if configued).

Throw if set to true but autoApproveOptions are not defined.


build_workflowOptional
  • Type: bool
  • Default: true if not a subproject

Define a GitHub workflow for building PRs.


build_workflow_optionsOptional
  • Type: projen.javascript.BuildWorkflowOptions

Options for PR build workflow.


~~build_workflow_triggers~~Optional
  • Deprecated: - Use buildWorkflowOptions.workflowTriggers

  • Type: projen.github.workflows.Triggers

  • Default: "{ pullRequest: {}, workflowDispatch: {} }"

Build workflow triggers.


bundler_optionsOptional
  • Type: projen.javascript.BundlerOptions

Options for Bundler.


check_licensesOptional
  • Type: projen.javascript.LicenseCheckerOptions
  • Default: no license checks are run during the build and all licenses will be accepted

Configure which licenses should be deemed acceptable for use by dependencies.

This setting will cause the build to fail, if any prohibited or not allowed licenses ares encountered.


code_covOptional
  • Type: bool
  • Default: false

Define a GitHub workflow step for sending code coverage metrics to https://codecov.io/ Uses codecov/codecov-action@v4 A secret is required for private repos. Configured with @codeCovTokenSecret.


code_cov_token_secretOptional
  • Type: str
  • Default: if this option is not specified, only public repositories are supported

Define the secret name for a specified https://codecov.io/ token A secret is required to send coverage for private repositories.


  • Type: str
  • Default: defaults to the value of authorName or "" if authorName is undefined.

License copyright owner.


  • Type: str
  • Default: current year

The copyright years to put in the LICENSE file.


dependabotOptional
  • Type: bool
  • Default: false

Use dependabot to handle dependency upgrades.

Cannot be used in conjunction with depsUpgrade.


dependabot_optionsOptional
  • Type: projen.github.DependabotOptions
  • Default: default options

Options for dependabot.


deps_upgradeOptional
  • Type: bool
  • Default: true

Use tasks and github workflows to handle dependency upgrades.

Cannot be used in conjunction with dependabot.


deps_upgrade_optionsOptional
  • Type: projen.javascript.UpgradeDependenciesOptions
  • Default: default options

Options for UpgradeDependencies.


gitignoreOptional
  • Type: typing.List[str]

Additional entries to .gitignore.


jestOptional
  • Type: bool
  • Default: true

Setup jest unit tests.


jest_optionsOptional
  • Type: projen.javascript.JestOptions
  • Default: default options

Jest options.


~~mutable_build~~Optional
  • Deprecated: - Use buildWorkflowOptions.mutableBuild

  • Type: bool

  • Default: true

Automatically update files modified during builds to pull-request branches.

This means that any files synthesized by projen or e.g. test snapshots will always be up-to-date before a PR is merged.

Implies that PR builds do not have anti-tamper checks.


~~npmignore~~Optional
  • Deprecated: - use project.addPackageIgnore

  • Type: typing.List[str]

Additional entries to .npmignore.


npmignore_enabledOptional
  • Type: bool
  • Default: true

Defines an .npmignore file. Normally this is only needed for libraries that are packaged as tarballs.


npm_ignore_optionsOptional
  • Type: projen.IgnoreFileOptions

Configuration options for .npmignore file.


packageOptional
  • Type: bool
  • Default: true

Defines a package task that will produce an npm tarball under the artifacts directory (e.g. dist).


prettierOptional
  • Type: bool
  • Default: false

Setup prettier.


prettier_optionsOptional
  • Type: projen.javascript.PrettierOptions
  • Default: default options

Prettier options.


projen_dev_dependencyOptional
  • Type: bool
  • Default: true if not a subproject

Indicates of "projen" should be installed as a devDependency.


projenrc_jsOptional
  • Type: bool
  • Default: true if projenrcJson is false

Generate (once) .projenrc.js (in JavaScript). Set to false in order to disable .projenrc.js generation.


projenrc_js_optionsOptional
  • Type: projen.javascript.ProjenrcOptions
  • Default: default options

Options for .projenrc.js.


projen_versionOptional
  • Type: str
  • Default: Defaults to the latest version.

Version of projen to install.


pull_request_templateOptional
  • Type: bool
  • Default: true

Include a GitHub pull request template.


pull_request_template_contentsOptional