Skip to content

create_gateway async

create_gateway(
    name: String,
    infrastructure_role_arn: String,
    configuration: GatewayConfiguration,
    *,
    config_overrides: Optional[AsyncECSClientConfig] = None,
    client_token: Optional[String] = None,
    deletion_protection: Optional[BoxedBoolean] = None,
    tags: Optional[Tags] = None,
    propagate_tags: Optional[PropagateGatewayTags] = None,
) -> CreateGatewayResponse

Creates a gateway. A gateway defines and dynamically manages ingress paths for your Amazon ECS services, handling traffic routing and infrastructure across multiple services while optimizing infrastructure usage. CreateGateway is a synchronous operation and the gateway is returned with a status of ACTIVE. The load balancers and other infrastructure that a gateway manages aren't created until a service in an associated cluster begins using the gateway.

To use this operation, you must have the iam:PassRole permission for the infrastructure role that you specify in infrastructureRoleArn.

Parameters:

  • name (String) –

    The name for the gateway. The name must be unique within your account and can be up to 255 characters.

  • infrastructure_role_arn (String) –

    The Amazon Resource Name (ARN) of the IAM role that the gateway assumes to create and manage infrastructure on your behalf.

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

    A unique, case-sensitive identifier that you provide to ensure that the operation completes no more than one time. If this token matches a previous request, the service ignores the request, but does not return an error.

  • deletion_protection (Optional[BoxedBoolean], default: None ) –

    Specifies whether to enable deletion protection for the gateway. When enabled, the gateway can't be deleted, and the gateway propagates this setting to the load balancers it manages. The default is true.

  • configuration (GatewayConfiguration) –

    The type-specific configuration for the gateway. Exactly one configuration variant must be set, and it determines the gateway type. For example, hostSharedAlb configures a gateway that uses Application Load Balancers with host-based routing.

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

    The metadata that you apply to the gateway to help you categorize and organize it. Each tag consists of a key and an optional value. Depending on propagateTags, these tags can be applied to the infrastructure the gateway manages.

  • propagate_tags (Optional[PropagateGatewayTags], default: None ) –

    Specifies whether to propagate the tags from the gateway to the infrastructure that the gateway manages. The default is GATEWAY.

Raises:

  • AccessDeniedException –

    You don't have authorization to perform the requested action.

  • ClientException –

    These errors are usually caused by a client action. This client action might be using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Or, it might be specifying an identifier that isn't valid.

  • InvalidParameterException –

    The specified parameter isn't valid. Review the available parameters for the API request.

    For more information about service event errors, see Amazon ECS service event messages.

  • ServerException –

    These errors are usually caused by a server issue.

  • UnsupportedFeatureException –

    The specified task isn't supported in this Region.

  • UnknownServiceError –

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

Examples:

To create a gateway This example creates a gateway named my-gateway that uses internet-facing Application Load Balancers with host-based routing in the specified subnets.

>>> await client.create_gateway(name='my-gateway', infrastructure_role_arn='arn:aws:iam::123456789012:role/ecsInfrastructureRole', configuration={'hostSharedAlb': {'networkConfiguration': {'subnets': ['subnet-0123456789abcdef0', 'subnet-0fedcba9876543210'], 'ipAddressType': 'ipv4'}, 'scheme': 'internet-facing', 'protocol': 'HTTPS', 'port': 443, 'maxAlbCount': 10, 'httpDesync': 'defensive'}}, tags=[{'key': 'team', 'value': 'web'}], propagate_tags='GATEWAY')
Source code in docs_src/capo_ecs/_services/async_ecs.py
async def create_gateway(
    self,
    name: "capo_ecs.types.string.String",
    infrastructure_role_arn: "capo_ecs.types.string.String",
    configuration: "capo_ecs.types.gateway_configuration.GatewayConfiguration",
    *,
    config_overrides: Optional[AsyncECSClientConfig] = None,
    client_token: Optional["capo_ecs.types.string.String"] = None,
    deletion_protection: Optional[
        "capo_ecs.types.boxed_boolean.BoxedBoolean"
    ] = None,
    tags: Optional["capo_ecs.types.tags.Tags"] = None,
    propagate_tags: Optional[
        "capo_ecs.types.propagate_gateway_tags.PropagateGatewayTags"
    ] = None,
) -> "capo_ecs.types.create_gateway_response.CreateGatewayResponse":
    """<p>Creates a gateway. A gateway defines and dynamically manages ingress paths for your Amazon ECS services, handling traffic routing and infrastructure across multiple services while optimizing infrastructure usage. <code>CreateGateway</code> is a synchronous operation and the gateway is returned with a status of <code>ACTIVE</code>. The load balancers and other infrastructure that a gateway manages aren't created until a service in an associated cluster begins using the gateway.</p> <p>To use this operation, you must have the <code>iam:PassRole</code> permission for the infrastructure role that you specify in <code>infrastructureRoleArn</code>.</p>

    Args:
        name: <p>The name for the gateway. The name must be unique within your account and can be up to 255 characters.</p>
        infrastructure_role_arn: <p>The Amazon Resource Name (ARN) of the IAM role that the gateway assumes to create and manage infrastructure on your behalf.</p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure that the operation completes no more than one time. If this token matches a previous request, the service ignores the request, but does not return an error.</p>
        deletion_protection: <p>Specifies whether to enable deletion protection for the gateway. When enabled, the gateway can't be deleted, and the gateway propagates this setting to the load balancers it manages. The default is <code>true</code>.</p>
        configuration: <p>The type-specific configuration for the gateway. Exactly one configuration variant must be set, and it determines the gateway type. For example, <code>hostSharedAlb</code> configures a gateway that uses Application Load Balancers with host-based routing.</p>
        tags: <p>The metadata that you apply to the gateway to help you categorize and organize it. Each tag consists of a key and an optional value. Depending on <code>propagateTags</code>, these tags can be applied to the infrastructure the gateway manages.</p>
        propagate_tags: <p>Specifies whether to propagate the tags from the gateway to the infrastructure that the gateway manages. The default is <code>GATEWAY</code>.</p>

    Raises:
        capo_ecs.errors.access_denied_exception.AccessDeniedException: <p>You don't have authorization to perform the requested action.</p>
        capo_ecs.errors.client_exception.ClientException: <p>These errors are usually caused by a client action. This client action might be using an action or resource on behalf of a user that doesn't have permissions to use the action or resource. Or, it might be specifying an identifier that isn't valid.</p>
        capo_ecs.errors.invalid_parameter_exception.InvalidParameterException: <p>The specified parameter isn't valid. Review the available parameters for the API request.</p> <p>For more information about service event errors, see <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-event-messages-list.html">Amazon ECS service event messages</a>. </p>
        capo_ecs.errors.server_exception.ServerException: <p>These errors are usually caused by a server issue.</p>
        capo_ecs.errors.unsupported_feature_exception.UnsupportedFeatureException: <p>The specified task isn't supported in this Region.</p>
        capo_ecs.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To create a gateway
        This example creates a gateway named my-gateway that uses internet-facing Application Load Balancers with host-based routing in the specified subnets.

        >>> await client.create_gateway(name='my-gateway', infrastructure_role_arn='arn:aws:iam::123456789012:role/ecsInfrastructureRole', configuration={'hostSharedAlb': {'networkConfiguration': {'subnets': ['subnet-0123456789abcdef0', 'subnet-0fedcba9876543210'], 'ipAddressType': 'ipv4'}, 'scheme': 'internet-facing', 'protocol': 'HTTPS', 'port': 443, 'maxAlbCount': 10, 'httpDesync': 'defensive'}}, tags=[{'key': 'team', 'value': 'web'}], propagate_tags='GATEWAY')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_ecs.types.create_gateway_request.CreateGatewayRequest]",
    ) -> AsyncOperationResponse[
        "capo_ecs.types.create_gateway_response.CreateGatewayResponse"
    ]:
        import capo_ecs._operations.amazon_ec2_container_service_v20141113.create_gateway

        (
            output,
            http_response,
        ) = await capo_ecs._operations.amazon_ec2_container_service_v20141113.create_gateway.async_create_gateway(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateGateway")
    )
    input_: capo_ecs.types.create_gateway_request.CreateGatewayRequest = {
        "name": name,
        "infrastructure_role_arn": infrastructure_role_arn,
        "configuration": configuration,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if deletion_protection is not None:
        input_["deletion_protection"] = deletion_protection
    if tags is not None:
        input_["tags"] = tags
    if propagate_tags is not None:
        input_["propagate_tags"] = propagate_tags

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output