Skip to content

update_infrastructure_configuration

update_infrastructure_configuration(
    infrastructure_configuration_arn: InfrastructureConfigurationArn,
    instance_profile_name: InstanceProfileNameType,
    client_token: ClientToken,
    *,
    config_overrides: Optional[imagebuilderClientConfig] = None,
    description: Optional[NonEmptyString] = None,
    instance_types: Optional[InstanceTypeList] = None,
    security_group_ids: Optional[SecurityGroupIds] = None,
    subnet_id: Optional[NonEmptyString] = None,
    logging: Optional[Logging] = None,
    key_pair: Optional[NonEmptyString] = None,
    terminate_instance_on_failure: Optional[NullableBoolean] = None,
    terminate_instance_on_completion: Optional[NullableBoolean] = None,
    sns_topic_arn: Optional[SnsTopicArn] = None,
    resource_tags: Optional[ResourceTagMap] = None,
    instance_metadata_options: Optional[InstanceMetadataOptions] = None,
    placement: Optional[Placement] = None,
    parent_instance: Optional[ParentInstanceConfiguration] = None,
) -> UpdateInfrastructureConfigurationResponse

Updates an infrastructure configuration. An infrastructure configuration defines the environment in which Image Builder builds and tests your image.

This operation doesn't support selective updates. The request replaces the configuration, so include every setting that you want to keep. Omitted optional properties are cleared.

Parameters:

  • infrastructure_configuration_arn (InfrastructureConfigurationArn) –

    The Amazon Resource Name (ARN) of the infrastructure configuration that you want to update.

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

    The description of the infrastructure configuration.

  • instance_types (Optional[InstanceTypeList], default: None ) –

    The instance types of the infrastructure configuration. You can specify one or more instance types to use for this build. Image Builder picks one of these instance types based on availability. If you don't specify instance types, Image Builder selects compatible instance types automatically. If you specify a Dedicated Host, Image Builder uses only instance types that the host supports.

  • instance_profile_name (InstanceProfileNameType) –

    The instance profile to associate with the instance used to customize your Amazon EC2 AMI. The instance profile must exist in your account.

  • security_group_ids (Optional[SecurityGroupIds], default: None ) –

    The security group IDs to associate with the instance used to customize your Amazon EC2 AMI.

  • subnet_id (Optional[NonEmptyString], default: None ) –

    The subnet ID in which to place the instance used to customize your Amazon EC2 AMI. If you specify subnetId, you must also specify one or more security group IDs in securityGroupIds. Otherwise, the request fails.

  • logging (Optional[Logging], default: None ) –

    The logging configuration of the infrastructure configuration. When you configure S3 logs, Image Builder writes logs from the build and test process to the specified bucket under the key prefix.

  • key_pair (Optional[NonEmptyString], default: None ) –

    The key pair of the infrastructure configuration. You can use this to log on to and debug the instance used to create your image.

  • terminate_instance_on_failure (Optional[NullableBoolean], default: None ) –

    Specifies whether to terminate the instance on failure. Set to false if you want Image Builder to retain the instance used to configure your AMI if the build or test phase of your workflow fails. Defaults to true.

  • terminate_instance_on_completion (Optional[NullableBoolean], default: None ) –

    Specifies whether Image Builder terminates build and test instances when image creation ends without a failure (success, cancellation, or expiration). Defaults to true.

  • sns_topic_arn (Optional[SnsTopicArn], default: None ) –

    The Amazon Resource Name (ARN) of the SNS topic to which Image Builder sends image build event notifications. Specify a standard topic. Image Builder doesn't support FIFO topics. Image Builder validates the topic when you create or update the configuration. You must have permission to publish to the topic.

    EC2 Image Builder can't send notifications to SNS topics that are encrypted using keys from other accounts. If your SNS topic is encrypted, the key must be owned by the same account that owns your Image Builder resources.

  • resource_tags (Optional[ResourceTagMap], default: None ) –

    The metadata tags to assign to the Amazon EC2 instance that Image Builder launches during the build process. Tags are formatted as key value pairs. Tag keys can't begin with aws: or match one of the following reserved keys: CreatedBy, Ec2ImageBuilderArn, Name, or Tags.

  • instance_metadata_options (Optional[InstanceMetadataOptions], default: None ) –

    The instance metadata service (IMDS) settings that Image Builder applies to the EC2 build and test instances it launches during image creation. If you don't set these options, the EC2 launch defaults for the instance apply. For more information about instance metadata options, see one of the following links:

  • placement (Optional[Placement], default: None ) –

    The instance placement settings that define where the build and test instances that Image Builder launches during image creation run. These settings don't affect instances that you launch from the output image.

  • parent_instance (Optional[ParentInstanceConfiguration], default: None ) –

    The Amazon EC2 Auto Scaling group that Image Builder takes the build instance from, instead of launching a new instance. This applies only to the build phase.

    To use this feature, the execution role for the build must have permissions to describe the Auto Scaling group, tag the instance while it's still in the group, and detach it from the group. For more information, see Build on an instance from an Auto Scaling group in the EC2 Image Builder User Guide.

  • client_token (ClientToken) –

    A unique, case-sensitive identifier you provide to ensure that the operation runs no more than one time. If you retry a request with the same client token, Image Builder returns the original response without running the operation again. For more information, see Ensuring idempotency in the Amazon EC2 API Reference.

Raises:

  • CallRateLimitExceededException –

    You have exceeded the permitted request rate for the Amazon EC2 APIs that Image Builder calls on your behalf. Retry with an increasing or variable delay between requests.

  • ClientException –

    A generic client error. This error usually indicates that the request failed a validation check, such as when a downstream service rejects a configured value.

  • ForbiddenException –

    You are not authorized to perform the requested operation.

  • IdempotentParameterMismatchException –

    You have specified a client token for an operation using parameter values that differ from a previous request that used the same client token.

  • InvalidRequestException –

    The request is malformed or otherwise invalid. Verify the request and try again.

  • ResourceInUseException –

    The resource that you are trying to operate on is currently in use. Review the message details and retry later.

  • ServiceException –

    An internal server error occurred while Image Builder processed the request. Retrying the request may succeed.

  • ServiceUnavailableException –

    The service is unable to process your request at this time.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

Update an infrastructure configuration The following example updates an infrastructure configuration to use larger instance types and to keep the build instance running when the image build fails.

>>> client.update_infrastructure_configuration(infrastructure_configuration_arn='arn:aws:imagebuilder:us-west-2:111122223333:infrastructure-configuration/my-example-infrastructure', description='An infrastructure configuration for Amazon Linux builds', instance_profile_name='EC2InstanceProfileForImageBuilder', instance_types=['t3.large', 't3.xlarge'], terminate_instance_on_failure=False, client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLEbbbbb')
Source code in docs_src/capo_imagebuilder/_services/imagebuilder.py
def update_infrastructure_configuration(
    self,
    infrastructure_configuration_arn: "capo_imagebuilder.types.infrastructure_configuration_arn.InfrastructureConfigurationArn",
    instance_profile_name: "capo_imagebuilder.types.instance_profile_name_type.InstanceProfileNameType",
    client_token: "capo_imagebuilder.types.client_token.ClientToken",
    *,
    config_overrides: Optional[imagebuilderClientConfig] = None,
    description: Optional[
        "capo_imagebuilder.types.non_empty_string.NonEmptyString"
    ] = None,
    instance_types: Optional[
        "capo_imagebuilder.types.instance_type_list.InstanceTypeList"
    ] = None,
    security_group_ids: Optional[
        "capo_imagebuilder.types.security_group_ids.SecurityGroupIds"
    ] = None,
    subnet_id: Optional[
        "capo_imagebuilder.types.non_empty_string.NonEmptyString"
    ] = None,
    logging: Optional["capo_imagebuilder.types.logging.Logging"] = None,
    key_pair: Optional[
        "capo_imagebuilder.types.non_empty_string.NonEmptyString"
    ] = None,
    terminate_instance_on_failure: Optional[
        "capo_imagebuilder.types.nullable_boolean.NullableBoolean"
    ] = None,
    terminate_instance_on_completion: Optional[
        "capo_imagebuilder.types.nullable_boolean.NullableBoolean"
    ] = None,
    sns_topic_arn: Optional[
        "capo_imagebuilder.types.sns_topic_arn.SnsTopicArn"
    ] = None,
    resource_tags: Optional[
        "capo_imagebuilder.types.resource_tag_map.ResourceTagMap"
    ] = None,
    instance_metadata_options: Optional[
        "capo_imagebuilder.types.instance_metadata_options.InstanceMetadataOptions"
    ] = None,
    placement: Optional["capo_imagebuilder.types.placement.Placement"] = None,
    parent_instance: Optional[
        "capo_imagebuilder.types.parent_instance_configuration.ParentInstanceConfiguration"
    ] = None,
) -> "capo_imagebuilder.types.update_infrastructure_configuration_response.UpdateInfrastructureConfigurationResponse":
    """<p>Updates an infrastructure configuration. An infrastructure configuration defines the environment in which Image Builder builds and tests your image.</p> <note> <p>This operation doesn't support selective updates. The request replaces the configuration, so include every setting that you want to keep. Omitted optional properties are cleared.</p> </note>

    Args:
        infrastructure_configuration_arn: <p>The Amazon Resource Name (ARN) of the infrastructure configuration that you want to update.</p>
        description: <p>The description of the infrastructure configuration.</p>
        instance_types: <p>The instance types of the infrastructure configuration. You can specify one or more instance types to use for this build. Image Builder picks one of these instance types based on availability. If you don't specify instance types, Image Builder selects compatible instance types automatically. If you specify a Dedicated Host, Image Builder uses only instance types that the host supports.</p>
        instance_profile_name: <p>The instance profile to associate with the instance used to customize your Amazon EC2 AMI. The instance profile must exist in your account.</p>
        security_group_ids: <p>The security group IDs to associate with the instance used to customize your Amazon EC2 AMI.</p>
        subnet_id: <p>The subnet ID in which to place the instance used to customize your Amazon EC2 AMI. If you specify <code>subnetId</code>, you must also specify one or more security group IDs in <code>securityGroupIds</code>. Otherwise, the request fails.</p>
        logging: <p>The logging configuration of the infrastructure configuration. When you configure S3 logs, Image Builder writes logs from the build and test process to the specified bucket under the key prefix.</p>
        key_pair: <p>The key pair of the infrastructure configuration. You can use this to log on to and debug the instance used to create your image.</p>
        terminate_instance_on_failure: <p>Specifies whether to terminate the instance on failure. Set to false if you want Image Builder to retain the instance used to configure your AMI if the build or test phase of your workflow fails. Defaults to <code>true</code>.</p>
        terminate_instance_on_completion: <p>Specifies whether Image Builder terminates build and test instances when image creation ends without a failure (success, cancellation, or expiration). Defaults to <code>true</code>.</p>
        sns_topic_arn: <p>The Amazon Resource Name (ARN) of the SNS topic to which Image Builder sends image build event notifications. Specify a standard topic. Image Builder doesn't support FIFO topics. Image Builder validates the topic when you create or update the configuration. You must have permission to publish to the topic.</p> <note> <p>EC2 Image Builder can't send notifications to SNS topics that are encrypted using keys from other accounts. If your SNS topic is encrypted, the key must be owned by the same account that owns your Image Builder resources.</p> </note>
        resource_tags: <p>The metadata tags to assign to the Amazon EC2 instance that Image Builder launches during the build process. Tags are formatted as key value pairs. Tag keys can't begin with <code>aws:</code> or match one of the following reserved keys: <code>CreatedBy</code>, <code>Ec2ImageBuilderArn</code>, <code>Name</code>, or <code>Tags</code>.</p>
        instance_metadata_options: <p>The instance metadata service (IMDS) settings that Image Builder applies to the EC2 build and test instances it launches during image creation. If you don't set these options, the EC2 launch defaults for the instance apply. For more information about instance metadata options, see one of the following links:</p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-options.html">Configure the instance metadata options</a> in the <i> <i>Amazon EC2 User Guide</i> </i> for Linux instances.</p> </li> <li> <p> <a href="https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/configuring-instance-metadata-options.html">Configure the instance metadata options</a> in the <i> <i>Amazon EC2 Windows Guide</i> </i> for Windows instances.</p> </li> </ul>
        placement: <p>The instance placement settings that define where the build and test instances that Image Builder launches during image creation run. These settings don't affect instances that you launch from the output image.</p>
        parent_instance: <p>The Amazon EC2 Auto Scaling group that Image Builder takes the build instance from, instead of launching a new instance. This applies only to the build phase.</p> <p>To use this feature, the execution role for the build must have permissions to describe the Auto Scaling group, tag the instance while it's still in the group, and detach it from the group. For more information, see <a href="https://docs.aws.amazon.com/imagebuilder/latest/userguide/infra-config-parent-instance.html">Build on an instance from an Auto Scaling group</a> in the <i>EC2 Image Builder User Guide</i>.</p>
        client_token: <p>A unique, case-sensitive identifier you provide to ensure that the operation runs no more than one time. If you retry a request with the same client token, Image Builder returns the original response without running the operation again. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensuring idempotency</a> in the <i>Amazon EC2 API Reference</i>.</p>

    Raises:
        capo_imagebuilder.errors.call_rate_limit_exceeded_exception.CallRateLimitExceededException: <p>You have exceeded the permitted request rate for the Amazon EC2 APIs that Image Builder calls on your behalf. Retry with an increasing or variable delay between requests.</p>
        capo_imagebuilder.errors.client_exception.ClientException: <p>A generic client error. This error usually indicates that the request failed a validation check, such as when a downstream service rejects a configured value.</p>
        capo_imagebuilder.errors.forbidden_exception.ForbiddenException: <p>You are not authorized to perform the requested operation.</p>
        capo_imagebuilder.errors.idempotent_parameter_mismatch_exception.IdempotentParameterMismatchException: <p>You have specified a client token for an operation using parameter values that differ from a previous request that used the same client token.</p>
        capo_imagebuilder.errors.invalid_request_exception.InvalidRequestException: <p>The request is malformed or otherwise invalid. Verify the request and try again.</p>
        capo_imagebuilder.errors.resource_in_use_exception.ResourceInUseException: <p>The resource that you are trying to operate on is currently in use. Review the message details and retry later.</p>
        capo_imagebuilder.errors.service_exception.ServiceException: <p>An internal server error occurred while Image Builder processed the request. Retrying the request may succeed.</p>
        capo_imagebuilder.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is unable to process your request at this time.</p>
        capo_imagebuilder.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Update an infrastructure configuration
        The following example updates an infrastructure configuration to use larger instance types and to keep the build instance running when the image build fails.

        >>> client.update_infrastructure_configuration(infrastructure_configuration_arn='arn:aws:imagebuilder:us-west-2:111122223333:infrastructure-configuration/my-example-infrastructure', description='An infrastructure configuration for Amazon Linux builds', instance_profile_name='EC2InstanceProfileForImageBuilder', instance_types=['t3.large', 't3.xlarge'], terminate_instance_on_failure=False, client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLEbbbbb')
    """

    def _handler(
        req: "OperationRequest[capo_imagebuilder.types.update_infrastructure_configuration_request.UpdateInfrastructureConfigurationRequest]",
    ) -> OperationResponse[
        "capo_imagebuilder.types.update_infrastructure_configuration_response.UpdateInfrastructureConfigurationResponse"
    ]:
        import capo_imagebuilder._operations.imagebuilder.update_infrastructure_configuration

        output, http_response = (
            capo_imagebuilder._operations.imagebuilder.update_infrastructure_configuration.update_infrastructure_configuration(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateInfrastructureConfiguration")
    )
    input_: capo_imagebuilder.types.update_infrastructure_configuration_request.UpdateInfrastructureConfigurationRequest = {
        "infrastructure_configuration_arn": infrastructure_configuration_arn,
        "instance_profile_name": instance_profile_name,
        "client_token": client_token,
    }
    if description is not None:
        input_["description"] = description
    if instance_types is not None:
        input_["instance_types"] = instance_types
    if security_group_ids is not None:
        input_["security_group_ids"] = security_group_ids
    if subnet_id is not None:
        input_["subnet_id"] = subnet_id
    if logging is not None:
        input_["logging"] = logging
    if key_pair is not None:
        input_["key_pair"] = key_pair
    if terminate_instance_on_failure is not None:
        input_["terminate_instance_on_failure"] = terminate_instance_on_failure
    if terminate_instance_on_completion is not None:
        input_["terminate_instance_on_completion"] = (
            terminate_instance_on_completion
        )
    if sns_topic_arn is not None:
        input_["sns_topic_arn"] = sns_topic_arn
    if resource_tags is not None:
        input_["resource_tags"] = resource_tags
    if instance_metadata_options is not None:
        input_["instance_metadata_options"] = instance_metadata_options
    if placement is not None:
        input_["placement"] = placement
    if parent_instance is not None:
        input_["parent_instance"] = parent_instance

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