Skip to content

create_service_network_vpc_association

create_service_network_vpc_association(
    service_network_identifier: ServiceNetworkIdentifierWithoutRegex,
    vpc_identifier: VpcId,
    *,
    config_overrides: Optional[VPCLatticeClientConfig] = None,
    client_token: Optional[ClientToken] = None,
    private_dns_enabled: Optional[Boolean] = None,
    security_group_ids: Optional[SecurityGroupList] = None,
    tags: Optional[TagMap] = None,
    dns_options: Optional[DnsOptions] = None,
) -> CreateServiceNetworkVpcAssociationResponse

Associates a VPC with a service network. When you associate a VPC with the service network, it enables all the resources within that VPC to be clients and communicate with other services in the service network. For more information, see Manage VPC associations in the Amazon VPC Lattice User Guide.

You can't use this operation if there is a disassociation in progress. If the association fails, retry by deleting the association and recreating it.

As a result of this operation, the association gets created in the service network account and the VPC owner account.

If you add a security group to the service network and VPC association, the association must continue to always have at least one security group. You can add or edit security groups at any time. However, to remove all security groups, you must first delete the association and recreate it without security groups.

Parameters:

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

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If you retry a request that completed successfully using the same client token and parameters, the retry succeeds without performing any actions. If the parameters aren't identical, the retry fails.

  • service_network_identifier (ServiceNetworkIdentifierWithoutRegex) –

    The ID or ARN of the service network. You must use an ARN if the resources are in different accounts.

  • vpc_identifier (VpcId) –

    The ID of the VPC.

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

    Indicates if private DNS is enabled for the VPC association.

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

    The IDs of the security groups. Security groups aren't added by default. You can add a security group to apply network level controls to control which resources in a VPC are allowed to access the service network and its services. For more information, see Control traffic to resources using security groups in the Amazon VPC User Guide.

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

    The tags for the association.

  • dns_options (Optional[DnsOptions], default: None ) –

    DNS options for the service network VPC association.

Raises:

Source code in docs_src/capo_vpc_lattice/_services/vpc_lattice.py
def create_service_network_vpc_association(
    self,
    service_network_identifier: "capo_vpc_lattice.types.service_network_identifier_without_regex.ServiceNetworkIdentifierWithoutRegex",
    vpc_identifier: "capo_vpc_lattice.types.vpc_id.VpcId",
    *,
    config_overrides: Optional[VPCLatticeClientConfig] = None,
    client_token: Optional[
        "capo_vpc_lattice.types.client_token.ClientToken"
    ] = None,
    private_dns_enabled: Optional["capo_vpc_lattice.types.boolean.Boolean"] = None,
    security_group_ids: Optional[
        "capo_vpc_lattice.types.security_group_list.SecurityGroupList"
    ] = None,
    tags: Optional["capo_vpc_lattice.types.tag_map.TagMap"] = None,
    dns_options: Optional["capo_vpc_lattice.types.dns_options.DnsOptions"] = None,
) -> "capo_vpc_lattice.types.create_service_network_vpc_association_response.CreateServiceNetworkVpcAssociationResponse":
    """<p>Associates a VPC with a service network. When you associate a VPC with the service network, it enables all the resources within that VPC to be clients and communicate with other services in the service network. For more information, see <a href="https://docs.aws.amazon.com/vpc-lattice/latest/ug/service-network-associations.html#service-network-vpc-associations">Manage VPC associations</a> in the <i>Amazon VPC Lattice User Guide</i>.</p> <p>You can't use this operation if there is a disassociation in progress. If the association fails, retry by deleting the association and recreating it.</p> <p>As a result of this operation, the association gets created in the service network account and the VPC owner account.</p> <p>If you add a security group to the service network and VPC association, the association must continue to always have at least one security group. You can add or edit security groups at any time. However, to remove all security groups, you must first delete the association and recreate it without security groups.</p>

    Args:
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If you retry a request that completed successfully using the same client token and parameters, the retry succeeds without performing any actions. If the parameters aren't identical, the retry fails.</p>
        service_network_identifier: <p>The ID or ARN of the service network. You must use an ARN if the resources are in different accounts.</p>
        vpc_identifier: <p>The ID of the VPC.</p>
        private_dns_enabled: <p> Indicates if private DNS is enabled for the VPC association. </p>
        security_group_ids: <p>The IDs of the security groups. Security groups aren't added by default. You can add a security group to apply network level controls to control which resources in a VPC are allowed to access the service network and its services. For more information, see <a href="https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html">Control traffic to resources using security groups</a> in the <i>Amazon VPC User Guide</i>.</p>
        tags: <p>The tags for the association.</p>
        dns_options: <p> DNS options for the service network VPC association. </p>

    Raises:
        capo_vpc_lattice.errors.access_denied_exception.AccessDeniedException: <p>The user does not have sufficient access to perform this action.</p>
        capo_vpc_lattice.errors.conflict_exception.ConflictException: <p>The request conflicts with the current state of the resource. Updating or deleting a resource can cause an inconsistent state.</p>
        capo_vpc_lattice.errors.internal_server_exception.InternalServerException: <p>An unexpected error occurred while processing the request.</p>
        capo_vpc_lattice.errors.resource_not_found_exception.ResourceNotFoundException: <p>The request references a resource that does not exist.</p>
        capo_vpc_lattice.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>The request would cause a service quota to be exceeded.</p>
        capo_vpc_lattice.errors.throttling_exception.ThrottlingException: <p>The limit on the number of requests per second was exceeded.</p>
        capo_vpc_lattice.errors.validation_exception.ValidationException: <p>The input does not satisfy the constraints specified by an Amazon Web Services service.</p>
        capo_vpc_lattice.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_vpc_lattice.types.create_service_network_vpc_association_request.CreateServiceNetworkVpcAssociationRequest]",
    ) -> OperationResponse[
        "capo_vpc_lattice.types.create_service_network_vpc_association_response.CreateServiceNetworkVpcAssociationResponse"
    ]:
        import capo_vpc_lattice._operations.mercury_control_plane.create_service_network_vpc_association

        output, http_response = (
            capo_vpc_lattice._operations.mercury_control_plane.create_service_network_vpc_association.create_service_network_vpc_association(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateServiceNetworkVpcAssociation")
    )
    input_: capo_vpc_lattice.types.create_service_network_vpc_association_request.CreateServiceNetworkVpcAssociationRequest = {
        "service_network_identifier": service_network_identifier,
        "vpc_identifier": vpc_identifier,
    }
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if private_dns_enabled is not None:
        input_["private_dns_enabled"] = private_dns_enabled
    if security_group_ids is not None:
        input_["security_group_ids"] = security_group_ids
    if tags is not None:
        input_["tags"] = tags
    if dns_options is not None:
        input_["dns_options"] = dns_options

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