EC2 / Client / associate_networking_flex_cost_allocation_policy

associate_networking_flex_cost_allocation_policy

EC2.Client.associate_networking_flex_cost_allocation_policy(**kwargs)

Associates a flex cost allocation policy with one or more network resources. You can associate the policy directly with specific resources by resource ID, or you can associate it with a scope of resources in an account, Amazon VPC, or subnet.

The following limits apply:

  • A request can associate up to 20 resources.

  • A policy can have up to 100 active associations.

  • A network resource can have only one active association, across all policies. If a resource is already associated, the response includes it in the failures with the code ResourceAlreadyAssociated.

See also: AWS API Documentation

Request Syntax

response = client.associate_networking_flex_cost_allocation_policy(
    FcaPolicyId='string',
    NetworkResourceIds=[
        'string',
    ],
    NetworkResourceScope={
        'ResourceType': 'account'|'vpc'|'subnet',
        'ResourceIds': [
            'string',
        ]
    },
    ClientToken='string',
    DryRun=True|False
)
Parameters:
  • FcaPolicyId (string) –

    [REQUIRED]

    The ID of the flex cost allocation policy to associate. This parameter is required.

  • NetworkResourceIds (list) –

    The IDs of the network resources to associate with the policy. You can specify from 1 to 20 resource IDs.

    You must specify NetworkResourceIds, NetworkResourceScope, or both. A request can include at most 20 distinct resources in total.

    • (string) –

  • NetworkResourceScope (dict) –

    The scope of network resources to associate with the policy. Use a scope to associate the policy with the resources in an account, Amazon VPC, or subnet.

    You must specify NetworkResourceScope, NetworkResourceIds, or both.

    • ResourceType (string) – [REQUIRED]

      The type of scope. This parameter is required. Valid values are account, vpc, and subnet.

    • ResourceIds (list) – [REQUIRED]

      The IDs of the resources owned by you that define the scope. You can specify from 1 to 20 IDs. This parameter is required.

      • (string) –

  • ClientToken (string) –

    Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensuring idempotency.

    This field is autopopulated if not provided.

  • DryRun (boolean) – Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

Return type:

dict

Returns:

Response Syntax

{
    'FcaPolicyAssociations': [
        {
            'FcaPolicyAssociationId': 'string',
            'FcaPolicyId': 'string',
            'NetworkResourceId': 'string',
            'OwnerAccount': 'string',
            'AssociatedAt': datetime(2015, 1, 1),
            'ExpectedEffectiveAt': datetime(2015, 1, 1),
            'AssociationMode': 'direct'|'scope',
            'ManagedBy': 'account'|'declarative-policy'
        },
    ],
    'FcaPolicyAssociationFailures': [
        {
            'ResourceId': 'string',
            'FailureCode': 'string',
            'FailureReason': 'string'
        },
    ]
}

Response Structure

  • (dict) –

    • FcaPolicyAssociations (list) –

      Information about the policy associations that were created.

      • (dict) –

        Describes an association between a flex cost allocation policy and a network resource.

        • FcaPolicyAssociationId (string) –

          The ID of the policy association.

        • FcaPolicyId (string) –

          The ID of the policy.

        • NetworkResourceId (string) –

          The ID of the associated network resource.

        • OwnerAccount (string) –

          The ID of the account that owns the association.

        • AssociatedAt (datetime) –

          The date and time when the association was created.

        • ExpectedEffectiveAt (datetime) –

          The date and time when the association is expected to apply to network traffic.

        • AssociationMode (string) –

          The mode of the association. Valid values:

          • direct - The policy is associated with specific resources by resource ID.

          • scope - The policy is associated with a scope of resources in an account, Amazon VPC, or subnet.

        • ManagedBy (string) –

          The entity that manages the association. Valid values are:

          • account - The account that owns the association created it.

          • declarative-policy - An Amazon Web Services Organizations declarative policy created the association. You can’t remove the association.

    • FcaPolicyAssociationFailures (list) –

      Information about the network resources that could not be associated with the policy.

      • (dict) –

        Describes a policy, association, or network resource that a Networking Flexible Cost Allocation operation failed to process.

        • ResourceId (string) –

          The ID of the resource that could not be processed.

        • FailureCode (string) –

          The code that identifies the type of failure. Possible values are:

          • ResourceNotFound - ( DeleteNetworkingFlexCostAllocationPolicies) The policy doesn’t exist or isn’t owned by your account.

          • InvalidResourceState - ( DeleteNetworkingFlexCostAllocationPolicies) The policy has active associations.

          • InvalidResource - ( AssociateNetworkingFlexCostAllocationPolicy) The resource ID is malformed, the resource type doesn’t match the policy, or the scope is an account other than yours. ( DisassociateNetworkingFlexCostAllocationPolicy) The association doesn’t exist or was already removed.

          • ResourceAlreadyAssociated - ( AssociateNetworkingFlexCostAllocationPolicy) The resource already has an active association.

          • InternalError - An internal error occurred. Retry the request.

        • FailureReason (string) –

          The reason for the failure.