AWS Proton parameters - AWS Proton

AWS Proton parameters

You can define and use parameters in your infrastructure as code (IaC) files to make them flexible and re-usable. You read a parameter value in your IaC files by referring to the parameter's name in the AWS Proton parameter namespace. AWS Proton injects parameter values into the rendered IaC files that it generates during resource provisioning. To process AWS CloudFormation IaC parameters, AWS Proton uses Jinja. To process Terraform IaC parameters, AWS Proton generates a Terraform parameter value file and relies on the parametrization ability built into HCL.

With CodeBuild provisioning, AWS Proton generates an input file that your code can import. The file is a JSON or HCL file, depending on a property in your template's manifest. For more information, see CodeBuild provisioning parameter details and examples.

You can refer to parameters in your environment, service, and component IaC files or provisioning code with the following requirements:

  • The length of each parameter name doesn't exceed 100 characters.

  • The length of the parameter namespace and resource name combined doesn't exceed the character limit for the resource name.

AWS Proton provisioning fails if these quotas are exceeded.

Parameter types

The following parameter types are available to you for reference in AWS Proton IaC files:

Input parameter

Environments and service instances can take input parameters that you define in a schema file that you associate with the environment or service template. You can refer to a resource's input parameters in the resource's IaC file. Component IaC files can refer to input parameters of the service instance that the component is attached to.

AWS Proton checks input parameter names against your schema file, and matches them with the parameters that are referenced in your IaC files to inject the input values that you provide in a spec file during resource provisioning.

Output parameter

You can define outputs in any of your IaC files. An output can be, for example, a name, ID, or ARN of one of the resources that the template provisions, or it can be a way to pass through one of the template's inputs. You can refer to these outputs in IaC files of other resources.

In CloudFormation IaC files,define output parameters in the Outputs: block. In a Terraform IaC file, define each output parameter using an output statement.

Resource parameter

AWS Proton automatically creates AWS Proton resource parameters. These parameters expose properties of the AWS Proton resource object. An example of a resource parameter is environment.name.

Using AWS Proton parameters in your IaC files

To read a parameter value in an IaC file, you refer to the parameter's name in the AWS Proton parameter namespace. For AWS CloudFormation IaC files, you use Jinja syntax and surround the parameter with pairs of curly braces and quotation marks.

The following table shows the reference syntax for each supported template language, with an example.

Template language Syntax Example: environment input named "VPC"

CloudFormation

"{{ parameter-name }}"

"{{ environment.inputs.VPC }}"

Terraform

var.parameter-name

var.environment.inputs.VPC

Generated Terraform variable definitions

Note

If you use CloudFormation dynamic parameters in your IaC file, you must escape them to prevent Jinja misinterpretation errors. For more information, see Troubleshooting AWS Proton

The following table lists namespace names for all AWS Proton resource parameters. Each template file type can use a different subset of the parameter namespace.

Template file Parameter type Parameter name Description

Environment

resource

environment.name

Environment name

input

environment.inputs.input-name

Schema-defined environment inputs

Service

resource

environment.name

environment.account_id

Environment name and AWS account ID

output

environment.outputs.output-name

Environment IaC file outputs

resource

service.branch_name

service.name

service.repository_connection_arn

service.repository_id

Service name and code repository

resource

service_instance.name

Service instance name

input

service_instance.inputs.input-name

Schema-defined service instance inputs

resource

service_instance.components.default.name

Attached default component name

output

service_instance.components.default.outputs.output-name

Attached default component IaC file outputs

Pipeline

resource

service_instance.environment.name

service_instance.environment.account_id

Service instance environment name and AWS account ID

output

service_instance.environment.outputs.output-name

Service instance environment IaC file outputs

input

pipeline.inputs.input-name

Schema-defined pipeline inputs

resource

service.branch_name

service.name

service.repository_connection_arn

service.repository_id

Service name and code repository

input

service_instance.inputs.input-name

Schema-defined service instance inputs

collection

{% for service_instance in service_instances %}...{% endfor %}

A collection of service instances that you can loop through

Component

resource

environment.name

environment.account_id

Environment name and AWS account account ID

output

environment.outputs.output-name

Environment IaC file outputs

resource

service.branch_name

service.name

service.repository_connection_arn

service.repository_id

Service name and code repository (attached components)

resource

service_instance.name

Service instance name (attached components)

input

service_instance.inputs.input-name

Schema-defined service instance inputs (attached components)

resource

component.name

Component name

For more information and examples, see the subtopics about parameters in IaC template files for different resource types and template languages.