Skip to content

register_default_host_management_configuration

register_default_host_management_configuration(
    permission_model: DHMCPermissionModel,
    *,
    config_overrides: Optional[SSMClientConfig] = None,
    role_arn: Optional[DHMCRoleArn] = None,
    overwrite: Optional[Boolean] = None,
) -> RegisterDefaultHostManagementConfigurationResult

Enables Default Host Management Configuration (DHMC) for the current Amazon Web Services account and Amazon Web Services Region. With DHMC enabled, you don't need to configure additional resources, such as an instance profile, to use your Amazon EC2 instances as managed nodes in Amazon Web Services Systems Manager.

To use this operation, you must have the following permissions:

  • You need the ssm:GetServiceSetting and ssm:UpdateServiceSetting permissions for the /ssm/managed-instance/default-ec2-instance-management-role service setting.

  • You need the iam:GetRole and iam:PassRole permissions for the role used for Default Host Management Configuration.

If PermissionModel is SERVICE_MANAGED, you also need the iam:CreateRole and iam:AttachRolePolicy permissions so that Amazon Web Services Systems Manager can create and configure the role on your behalf.

Parameters:

  • permission_model (DHMCPermissionModel) –

    The permission model that determines how the IAM role for Default Host Management Configuration is provided.

    The permission model can be one of the following values:

    SERVICE_MANAGED

    Amazon Web Services Systems Manager creates and manages the role on your behalf.

    SELF_MANAGED

    You provide the role to register in RoleArn.

  • role_arn (Optional[DHMCRoleArn], default: None ) –

    The Amazon Resource Name (ARN) of the self-managed IAM role that you register for Default Host Management Configuration. The requirement for this value depends on the permission model:

    • If PermissionModel is SELF_MANAGED, this value is required.

    • If PermissionModel is SERVICE_MANAGED, this value must not be set.

  • overwrite (Optional[Boolean], default: None ) –

    Specifies whether to override the role that is currently registered for Default Host Management Configuration. The default is false, which acts as a guardrail against accidentally replacing an existing configuration. Set this to true to replace the currently registered role.

Raises:

Source code in docs_src/capo_ssm/_services/ssm.py
def register_default_host_management_configuration(
    self,
    permission_model: "capo_ssm.types.dhmc_permission_model.DHMCPermissionModel",
    *,
    config_overrides: Optional[SSMClientConfig] = None,
    role_arn: Optional["capo_ssm.types.dhmc_role_arn.DHMCRoleArn"] = None,
    overwrite: Optional["capo_ssm.types.boolean.Boolean"] = None,
) -> "capo_ssm.types.register_default_host_management_configuration_result.RegisterDefaultHostManagementConfigurationResult":
    """<p>Enables Default Host Management Configuration (DHMC) for the current Amazon Web Services account and Amazon Web Services Region. With DHMC enabled, you don't need to configure additional resources, such as an instance profile, to use your Amazon EC2 instances as managed nodes in Amazon Web Services Systems Manager.</p> <p>To use this operation, you must have the following permissions:</p> <ul> <li> <p>You need the <code>ssm:GetServiceSetting</code> and <code>ssm:UpdateServiceSetting</code> permissions for the <code>/ssm/managed-instance/default-ec2-instance-management-role</code> service setting.</p> </li> <li> <p>You need the <code>iam:GetRole</code> and <code>iam:PassRole</code> permissions for the role used for Default Host Management Configuration.</p> </li> </ul> <p>If <code>PermissionModel</code> is <code>SERVICE_MANAGED</code>, you also need the <code>iam:CreateRole</code> and <code>iam:AttachRolePolicy</code> permissions so that Amazon Web Services Systems Manager can create and configure the role on your behalf.</p>

    Args:
        permission_model: <p>The permission model that determines how the IAM role for Default Host Management Configuration is provided.</p> <p>The permission model can be one of the following values:</p> <dl> <dt>SERVICE_MANAGED</dt> <dd> <p>Amazon Web Services Systems Manager creates and manages the role on your behalf.</p> </dd> <dt>SELF_MANAGED</dt> <dd> <p>You provide the role to register in <code>RoleArn</code>.</p> </dd> </dl>
        role_arn: <p>The Amazon Resource Name (ARN) of the self-managed IAM role that you register for Default Host Management Configuration. The requirement for this value depends on the permission model:</p> <ul> <li> <p>If <code>PermissionModel</code> is <code>SELF_MANAGED</code>, this value is required.</p> </li> <li> <p>If <code>PermissionModel</code> is <code>SERVICE_MANAGED</code>, this value must not be set.</p> </li> </ul>
        overwrite: <p>Specifies whether to override the role that is currently registered for Default Host Management Configuration. The default is <code>false</code>, which acts as a guardrail against accidentally replacing an existing configuration. Set this to <code>true</code> to replace the currently registered role.</p>

    Raises:
        capo_ssm.errors.internal_server_error.InternalServerError: <p>An error occurred on the server side.</p>
        capo_ssm.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ssm.types.register_default_host_management_configuration_request.RegisterDefaultHostManagementConfigurationRequest]",
    ) -> OperationResponse[
        "capo_ssm.types.register_default_host_management_configuration_result.RegisterDefaultHostManagementConfigurationResult"
    ]:
        import capo_ssm._operations.amazon_ssm.register_default_host_management_configuration

        output, http_response = (
            capo_ssm._operations.amazon_ssm.register_default_host_management_configuration.register_default_host_management_configuration(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("RegisterDefaultHostManagementConfiguration"),
    )
    input_: capo_ssm.types.register_default_host_management_configuration_request.RegisterDefaultHostManagementConfigurationRequest = {
        "permission_model": permission_model
    }
    if role_arn is not None:
        input_["role_arn"] = role_arn
    if overwrite is not None:
        input_["overwrite"] = overwrite

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