Skip to content

create_environment

create_environment(
    name: ResourceName,
    template_name: ResourceName,
    template_major_version: TemplateVersionPart,
    spec: SpecContents,
    *,
    config_overrides: Optional[ProtonClientConfig] = None,
    template_minor_version: Optional[TemplateVersionPart] = None,
    description: Optional[Description] = None,
    proton_service_role_arn: Optional[Arn] = None,
    environment_account_connection_id: Optional[EnvironmentAccountConnectionId] = None,
    tags: Optional[TagList] = None,
    provisioning_repository: Optional[RepositoryBranchInput] = None,
    component_role_arn: Optional[RoleArn] = None,
    codebuild_role_arn: Optional[RoleArn] = None,
) -> CreateEnvironmentOutput

Deploy a new environment. An Proton environment is created from an environment template that defines infrastructure and resources that can be shared across services.

You can provision environments using the following methods:

  • Amazon Web Services-managed provisioning: Proton makes direct calls to provision your resources.

  • Self-managed provisioning: Proton makes pull requests on your repository to provide compiled infrastructure as code (IaC) files that your IaC engine uses to provision resources.

For more information, see Environments and Provisioning methods in the Proton User Guide.

Parameters:

  • name (ResourceName) –

    The name of the environment.

  • template_name (ResourceName) –

    The name of the environment template. For more information, see Environment Templates in the Proton User Guide.

  • template_major_version (TemplateVersionPart) –

    The major version of the environment template.

  • template_minor_version (Optional[TemplateVersionPart], default: None ) –

    The minor version of the environment template.

  • description (Optional[Description], default: None ) –

    A description of the environment that's being created and deployed.

  • spec (SpecContents) –

    A YAML formatted string that provides inputs as defined in the environment template bundle schema file. For more information, see Environments in the Proton User Guide.

  • proton_service_role_arn (Optional[Arn], default: None ) –

    The Amazon Resource Name (ARN) of the Proton service role that allows Proton to make calls to other services on your behalf.

    To use Amazon Web Services-managed provisioning for the environment, specify either the environmentAccountConnectionId or protonServiceRoleArn parameter and omit the provisioningRepository parameter.

  • environment_account_connection_id (Optional[EnvironmentAccountConnectionId], default: None ) –

    The ID of the environment account connection that you provide if you're provisioning your environment infrastructure resources to an environment account. For more information, see Environment account connections in the Proton User guide.

    To use Amazon Web Services-managed provisioning for the environment, specify either the environmentAccountConnectionId or protonServiceRoleArn parameter and omit the provisioningRepository parameter.

  • tags (Optional[TagList], default: None ) –

    An optional list of metadata items that you can associate with the Proton environment. A tag is a key-value pair.

    For more information, see Proton resources and tagging in the Proton User Guide.

  • provisioning_repository (Optional[RepositoryBranchInput], default: None ) –

    The linked repository that you use to host your rendered infrastructure templates for self-managed provisioning. A linked repository is a repository that has been registered with Proton. For more information, see CreateRepository.

    To use self-managed provisioning for the environment, specify this parameter and omit the environmentAccountConnectionId and protonServiceRoleArn parameters.

  • component_role_arn (Optional[RoleArn], default: None ) –

    The Amazon Resource Name (ARN) of the IAM service role that Proton uses when provisioning directly defined components in this environment. It determines the scope of infrastructure that a component can provision.

    You must specify componentRoleArn to allow directly defined components to be associated with this environment.

    For more information about components, see Proton components in the Proton User Guide.

  • codebuild_role_arn (Optional[RoleArn], default: None ) –

    The Amazon Resource Name (ARN) of the IAM service role that allows Proton to provision infrastructure using CodeBuild-based provisioning on your behalf.

    To use CodeBuild-based provisioning for the environment or for any service instance running in the environment, specify either the environmentAccountConnectionId or codebuildRoleArn parameter.

Raises:

Source code in docs_src/capo_proton/_services/proton.py
def create_environment(
    self,
    name: "capo_proton.types.resource_name.ResourceName",
    template_name: "capo_proton.types.resource_name.ResourceName",
    template_major_version: "capo_proton.types.template_version_part.TemplateVersionPart",
    spec: "capo_proton.types.spec_contents.SpecContents",
    *,
    config_overrides: Optional[ProtonClientConfig] = None,
    template_minor_version: Optional[
        "capo_proton.types.template_version_part.TemplateVersionPart"
    ] = None,
    description: Optional["capo_proton.types.description.Description"] = None,
    proton_service_role_arn: Optional["capo_proton.types.arn.Arn"] = None,
    environment_account_connection_id: Optional[
        "capo_proton.types.environment_account_connection_id.EnvironmentAccountConnectionId"
    ] = None,
    tags: Optional["capo_proton.types.tag_list.TagList"] = None,
    provisioning_repository: Optional[
        "capo_proton.types.repository_branch_input.RepositoryBranchInput"
    ] = None,
    component_role_arn: Optional["capo_proton.types.role_arn.RoleArn"] = None,
    codebuild_role_arn: Optional["capo_proton.types.role_arn.RoleArn"] = None,
) -> "capo_proton.types.create_environment_output.CreateEnvironmentOutput":
    """<p>Deploy a new environment. An Proton environment is created from an environment template that defines infrastructure and resources that can be shared across services.</p> <p class="title"> <b>You can provision environments using the following methods:</b> </p> <ul> <li> <p>Amazon Web Services-managed provisioning: Proton makes direct calls to provision your resources.</p> </li> <li> <p>Self-managed provisioning: Proton makes pull requests on your repository to provide compiled infrastructure as code (IaC) files that your IaC engine uses to provision resources.</p> </li> </ul> <p>For more information, see <a href="https://docs.aws.amazon.com/proton/latest/userguide/ag-environments.html">Environments</a> and <a href="https://docs.aws.amazon.com/proton/latest/userguide/ag-works-prov-methods.html">Provisioning methods</a> in the <i>Proton User Guide</i>.</p>

    Args:
        name: <p>The name of the environment.</p>
        template_name: <p>The name of the environment template. For more information, see <a href="https://docs.aws.amazon.com/proton/latest/userguide/ag-templates.html">Environment Templates</a> in the <i>Proton User Guide</i>.</p>
        template_major_version: <p>The major version of the environment template.</p>
        template_minor_version: <p>The minor version of the environment template.</p>
        description: <p>A description of the environment that's being created and deployed.</p>
        spec: <p>A YAML formatted string that provides inputs as defined in the environment template bundle schema file. For more information, see <a href="https://docs.aws.amazon.com/proton/latest/userguide/ag-environments.html">Environments</a> in the <i>Proton User Guide</i>.</p>
        proton_service_role_arn: <p>The Amazon Resource Name (ARN) of the Proton service role that allows Proton to make calls to other services on your behalf.</p> <p>To use Amazon Web Services-managed provisioning for the environment, specify either the <code>environmentAccountConnectionId</code> or <code>protonServiceRoleArn</code> parameter and omit the <code>provisioningRepository</code> parameter.</p>
        environment_account_connection_id: <p>The ID of the environment account connection that you provide if you're provisioning your environment infrastructure resources to an environment account. For more information, see <a href="https://docs.aws.amazon.com/proton/latest/userguide/ag-env-account-connections.html">Environment account connections</a> in the <i>Proton User guide</i>.</p> <p>To use Amazon Web Services-managed provisioning for the environment, specify either the <code>environmentAccountConnectionId</code> or <code>protonServiceRoleArn</code> parameter and omit the <code>provisioningRepository</code> parameter.</p>
        tags: <p>An optional list of metadata items that you can associate with the Proton environment. A tag is a key-value pair.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/proton/latest/userguide/resources.html">Proton resources and tagging</a> in the <i>Proton User Guide</i>.</p>
        provisioning_repository: <p>The linked repository that you use to host your rendered infrastructure templates for self-managed provisioning. A linked repository is a repository that has been registered with Proton. For more information, see <a>CreateRepository</a>.</p> <p>To use self-managed provisioning for the environment, specify this parameter and omit the <code>environmentAccountConnectionId</code> and <code>protonServiceRoleArn</code> parameters.</p>
        component_role_arn: <p>The Amazon Resource Name (ARN) of the IAM service role that Proton uses when provisioning directly defined components in this environment. It determines the scope of infrastructure that a component can provision.</p> <p>You must specify <code>componentRoleArn</code> to allow directly defined components to be associated with this environment.</p> <p>For more information about components, see <a href="https://docs.aws.amazon.com/proton/latest/userguide/ag-components.html">Proton components</a> in the <i>Proton User Guide</i>.</p>
        codebuild_role_arn: <p>The Amazon Resource Name (ARN) of the IAM service role that allows Proton to provision infrastructure using CodeBuild-based provisioning on your behalf.</p> <p>To use CodeBuild-based provisioning for the environment or for any service instance running in the environment, specify either the <code>environmentAccountConnectionId</code> or <code>codebuildRoleArn</code> parameter.</p>

    Raises:
        capo_proton.errors.access_denied_exception.AccessDeniedException: <p>There <i>isn't</i> sufficient access for performing this action.</p>
        capo_proton.errors.conflict_exception.ConflictException: <p>The request <i>couldn't</i> be made due to a conflicting operation or resource.</p>
        capo_proton.errors.internal_server_exception.InternalServerException: <p>The request failed to register with the service.</p>
        capo_proton.errors.resource_not_found_exception.ResourceNotFoundException: <p>The requested resource <i>wasn't</i> found.</p>
        capo_proton.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>A quota was exceeded. For more information, see <a href="https://docs.aws.amazon.com/proton/latest/userguide/ag-limits.html">Proton Quotas</a> in the <i>Proton User Guide</i>.</p>
        capo_proton.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_proton.errors.validation_exception.ValidationException: <p>The input is invalid or an out-of-range value was supplied for the input parameter.</p>
        capo_proton.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_proton.types.create_environment_input.CreateEnvironmentInput]",
    ) -> OperationResponse[
        "capo_proton.types.create_environment_output.CreateEnvironmentOutput"
    ]:
        import capo_proton._operations.aws_proton20200720.create_environment

        output, http_response = (
            capo_proton._operations.aws_proton20200720.create_environment.create_environment(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_proton.types.create_environment_input.CreateEnvironmentInput",
    ) -> dict[str, Any]:
        import capo_proton.types.create_environment_input

        return capo_proton.types.create_environment_input.redact_sensitive(input_)

    def _redact_output(
        output: "capo_proton.types.create_environment_output.CreateEnvironmentOutput",
    ) -> dict[str, Any]:
        import capo_proton.types.create_environment_output

        return capo_proton.types.create_environment_output.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateEnvironment",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_proton.types.create_environment_input.CreateEnvironmentInput = {
        "name": name,
        "template_name": template_name,
        "template_major_version": template_major_version,
        "spec": spec,
    }
    if template_minor_version is not None:
        input_["template_minor_version"] = template_minor_version
    if description is not None:
        input_["description"] = description
    if proton_service_role_arn is not None:
        input_["proton_service_role_arn"] = proton_service_role_arn
    if environment_account_connection_id is not None:
        input_["environment_account_connection_id"] = (
            environment_account_connection_id
        )
    if tags is not None:
        input_["tags"] = tags
    if provisioning_repository is not None:
        input_["provisioning_repository"] = provisioning_repository
    if component_role_arn is not None:
        input_["component_role_arn"] = component_role_arn
    if codebuild_role_arn is not None:
        input_["codebuild_role_arn"] = codebuild_role_arn

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output