Skip to content

create_component

create_component(
    name: ResourceName,
    template_file: TemplateFileContents,
    manifest: TemplateManifestContents,
    *,
    config_overrides: Optional[ProtonClientConfig] = None,
    description: Optional[Description] = None,
    service_name: Optional[ResourceName] = None,
    service_instance_name: Optional[ResourceName] = None,
    environment_name: Optional[ResourceName] = None,
    service_spec: Optional[SpecContents] = None,
    tags: Optional[TagList] = None,
    client_token: Optional[ClientToken] = None,
) -> CreateComponentOutput

Create an Proton component. A component is an infrastructure extension for a service instance.

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

Parameters:

  • name (ResourceName) –

    The customer-provided name of the component.

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

    An optional customer-provided description of the component.

  • service_name (Optional[ResourceName], default: None ) –

    The name of the service that serviceInstanceName is associated with. If you don't specify this, the component isn't attached to any service instance. Specify both serviceInstanceName and serviceName or neither of them.

  • service_instance_name (Optional[ResourceName], default: None ) –

    The name of the service instance that you want to attach this component to. If you don't specify this, the component isn't attached to any service instance. Specify both serviceInstanceName and serviceName or neither of them.

  • environment_name (Optional[ResourceName], default: None ) –

    The name of the Proton environment that you want to associate this component with. You must specify this when you don't specify serviceInstanceName and serviceName.

  • template_file (TemplateFileContents) –

    A path to the Infrastructure as Code (IaC) file describing infrastructure that a custom component provisions.

    Components support a single IaC file, even if you use Terraform as your template language.

  • manifest (TemplateManifestContents) –

    A path to a manifest file that lists the Infrastructure as Code (IaC) file, template language, and rendering engine for infrastructure that a custom component provisions.

  • service_spec (Optional[SpecContents], default: None ) –

    The service spec that you want the component to use to access service inputs. Set this only when you attach the component to a service instance.

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

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

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

  • client_token (Optional[ClientToken], default: None ) –

    The client token for the created component.

Raises:

Source code in docs_src/capo_proton/_services/proton.py
def create_component(
    self,
    name: "capo_proton.types.resource_name.ResourceName",
    template_file: "capo_proton.types.template_file_contents.TemplateFileContents",
    manifest: "capo_proton.types.template_manifest_contents.TemplateManifestContents",
    *,
    config_overrides: Optional[ProtonClientConfig] = None,
    description: Optional["capo_proton.types.description.Description"] = None,
    service_name: Optional["capo_proton.types.resource_name.ResourceName"] = None,
    service_instance_name: Optional[
        "capo_proton.types.resource_name.ResourceName"
    ] = None,
    environment_name: Optional[
        "capo_proton.types.resource_name.ResourceName"
    ] = None,
    service_spec: Optional["capo_proton.types.spec_contents.SpecContents"] = None,
    tags: Optional["capo_proton.types.tag_list.TagList"] = None,
    client_token: Optional["capo_proton.types.client_token.ClientToken"] = None,
) -> "capo_proton.types.create_component_output.CreateComponentOutput":
    """<p>Create an Proton component. A component is an infrastructure extension for a service instance.</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>

    Args:
        name: <p>The customer-provided name of the component.</p>
        description: <p>An optional customer-provided description of the component.</p>
        service_name: <p>The name of the service that <code>serviceInstanceName</code> is associated with. If you don't specify this, the component isn't attached to any service instance. Specify both <code>serviceInstanceName</code> and <code>serviceName</code> or neither of them.</p>
        service_instance_name: <p>The name of the service instance that you want to attach this component to. If you don't specify this, the component isn't attached to any service instance. Specify both <code>serviceInstanceName</code> and <code>serviceName</code> or neither of them.</p>
        environment_name: <p>The name of the Proton environment that you want to associate this component with. You must specify this when you don't specify <code>serviceInstanceName</code> and <code>serviceName</code>.</p>
        template_file: <p>A path to the Infrastructure as Code (IaC) file describing infrastructure that a custom component provisions.</p> <note> <p>Components support a single IaC file, even if you use Terraform as your template language.</p> </note>
        manifest: <p>A path to a manifest file that lists the Infrastructure as Code (IaC) file, template language, and rendering engine for infrastructure that a custom component provisions.</p>
        service_spec: <p>The service spec that you want the component to use to access service inputs. Set this only when you attach the component to a service instance.</p>
        tags: <p>An optional list of metadata items that you can associate with the Proton component. 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>
        client_token: <p>The client token for the created component.</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_component_input.CreateComponentInput]",
    ) -> OperationResponse[
        "capo_proton.types.create_component_output.CreateComponentOutput"
    ]:
        import capo_proton._operations.aws_proton20200720.create_component

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

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

        return capo_proton.types.create_component_input.redact_sensitive(input_)

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

        return capo_proton.types.create_component_output.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "CreateComponent",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_proton.types.create_component_input.CreateComponentInput = {
        "name": name,
        "template_file": template_file,
        "manifest": manifest,
    }
    if description is not None:
        input_["description"] = description
    if service_name is not None:
        input_["service_name"] = service_name
    if service_instance_name is not None:
        input_["service_instance_name"] = service_instance_name
    if environment_name is not None:
        input_["environment_name"] = environment_name
    if service_spec is not None:
        input_["service_spec"] = service_spec
    if tags is not None:
        input_["tags"] = tags
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token

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