Repository: ansible-collections/amazon.aws

Issue:
[6.0.0] Drop support for EC2 Classic networking
### Summary

[Amazon announced that they're dropping support for "EC2 Classic" (non-VPC networking) in July 2021](https://aws.amazon.com/blogs/aws/ec2-classic-is-retiring-heres-how-to-prepare/).  This is sometimes referred to as "Classic-Link"

Specifically stating that:
> On August 15, 2022 [Amazon AWS] expect all migrations to be complete, with no remaining EC2-Classic resources present in any AWS account.

We're now past that date, it's reasonable to start dropping support for EC2-Classic for 6.0.0.  Anyone who's got an exception from Amazon to continue to support EC2 Classic will still be able to use our 5.x releases.

### Issue Type

Feature Idea

### Component Name

(Known examples)
plugins/modules/ec2_eip.py (`in_vpc` parameter - `Domain` when passed to boto3 should now always be `vpc`)
plugins/modules/ec2_vpc_net.py
plugins/modules/ec2_security_group.py
plugins/module_utils/botocore.py
plugins/lookup/aws_account_attribute.py  (see also #1092)

### Additional Information

**Note**: This does _NOT_ include Classic ELBs which _are_ still supported.

### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/module_utils/botocore.py`](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/module_utils/botocore.py)
* [`plugins/modules/ec2_security_group.py`](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/modules/ec2_security_group.py)
* [`plugins/modules/ec2_vpc_net.py`](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/modules/ec2_vpc_net.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @Razique @adq @jillr @s-hertel
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/plugins/modules/ec2_vpc_net.py b/plugins/modules/ec2_vpc_net.py
--- a/plugins/modules/ec2_vpc_net.py
+++ b/plugins/modules/ec2_vpc_net.py
@@ -135,11 +135,6 @@
                 }
             }
         ]
-    classic_link_enabled:
-      description: indicates whether ClassicLink is enabled
-      returned: always
-      type: bool
-      sample: false
     dhcp_options_id:
       description: the id of the DHCP options associated with this VPC
       returned: always
@@ -250,16 +245,6 @@ def vpc_exists(module, vpc, name, cidr_block, multi):
     return None
 
 
-def get_classic_link_status(module, connection, vpc_id):
-    try:
-        results = connection.describe_vpc_classic_link(aws_retry=True, VpcIds=[vpc_id])
-        return results['Vpcs'][0].get('ClassicLinkEnabled')
-    except is_boto3_error_message('The functionality you requested is not available in this region.'):
-        return False
-    except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:  # pylint: disable=duplicate-except
-        module.fail_json_aws(e, msg="Failed to describe VPCs")
-
-
 def wait_for_vpc_to_exist(module, connection, **params):
     # wait for vpc to be available
     try:
@@ -287,8 +272,6 @@ def get_vpc(module, connection, vpc_id, wait=True):
     except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
         module.fail_json_aws(e, msg="Failed to describe VPCs")
 
-    vpc_obj['ClassicLinkEnabled'] = get_classic_link_status(module, connection, vpc_id)
-
     return vpc_obj
 
 
diff --git a/plugins/modules/ec2_vpc_net_info.py b/plugins/modules/ec2_vpc_net_info.py
--- a/plugins/modules/ec2_vpc_net_info.py
+++ b/plugins/modules/ec2_vpc_net_info.py
@@ -79,14 +79,6 @@
             description: The IPv4 CIDR block assigned to the VPC.
             returned: always
             type: str
-        classic_link_dns_supported:
-            description: True/False depending on attribute setting for classic link DNS support.
-            returned: always
-            type: bool
-        classic_link_enabled:
-            description: True/False depending on if classic link support is enabled.
-            returned: always
-            type: bool
         enable_dns_hostnames:
             description: True/False depending on attribute setting for DNS hostnames support.
             returned: always
@@ -186,27 +178,13 @@ def describe_vpcs(connection, module):
         module.fail_json_aws(e, msg="Unable to describe VPCs {0}".format(vpc_ids))
 
     # We can get these results in bulk but still needs two separate calls to the API
-    cl_enabled = {}
-    cl_dns_support = {}
     dns_support = {}
     dns_hostnames = {}
     # Loop through the results and add the other VPC attributes we gathered
     for vpc in response['Vpcs']:
         error_message = "Unable to describe VPC attribute {0} on VPC {1}"
-        cl_enabled = describe_classic_links(module, connection, vpc['VpcId'], 'ClassicLinkEnabled', error_message)
-        cl_dns_support = describe_classic_links(module, connection, vpc['VpcId'], 'ClassicLinkDnsSupported', error_message)
         dns_support = describe_vpc_attribute(module, connection, vpc['VpcId'], 'enableDnsSupport', error_message)
         dns_hostnames = describe_vpc_attribute(module, connection, vpc['VpcId'], 'enableDnsHostnames', error_message)
-        if cl_enabled:
-            # loop through the ClassicLink Enabled results and add the value for the correct VPC
-            for item in cl_enabled['Vpcs']:
-                if vpc['VpcId'] == item['VpcId']:
-                    vpc['ClassicLinkEnabled'] = item.get('ClassicLinkEnabled', False)
-        if cl_dns_support:
-            # loop through the ClassicLink DNS support results and add the value for the correct VPC
-            for item in cl_dns_support['Vpcs']:
-                if vpc['VpcId'] == item['VpcId']:
-                    vpc['ClassicLinkDnsSupported'] = item.get('ClassicLinkDnsSupported', False)
 
         # add the two DNS attributes
         if dns_support:
@@ -222,22 +200,6 @@ def describe_vpcs(connection, module):
     module.exit_json(vpcs=vpc_info)
 
 
-def describe_classic_links(module, connection, vpc, attribute, error_message):
-    result = None
-    try:
-        if attribute == "ClassicLinkEnabled":
-            result = connection.describe_vpc_classic_link(VpcIds=[vpc], aws_retry=True)
-        else:
-            result = connection.describe_vpc_classic_link_dns_support(VpcIds=[vpc], aws_retry=True)
-    except is_boto3_error_code('UnsupportedOperation'):
-        result = {'Vpcs': [{'VpcId': vpc}]}
-    except is_boto3_error_code('InvalidVpcID.NotFound'):
-        module.warn(error_message.format(attribute, vpc))
-    except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:  # pylint: disable=duplicate-except
-        module.fail_json_aws(e, msg='Unable to describe if {0} is enabled'.format(attribute))
-    return result
-
-
 def describe_vpc_attribute(module, connection, vpc, attribute, error_message):
     result = None
     try:


Test patch:
diff --git a/tests/integration/targets/ec2_vpc_net/tasks/main.yml b/tests/integration/targets/ec2_vpc_net/tasks/main.yml
--- a/tests/integration/targets/ec2_vpc_net/tasks/main.yml
+++ b/tests/integration/targets/ec2_vpc_net/tasks/main.yml
@@ -114,7 +114,6 @@
           - result.vpc.cidr_block_association_set[0].association_id.startswith("vpc-cidr-assoc-")
           - result.vpc.cidr_block_association_set[0].cidr_block == vpc_cidr
           - result.vpc.cidr_block_association_set[0].cidr_block_state.state in ["associated", "associating"]
-          - '"classic_link_enabled" in result.vpc'
           - result.vpc.dhcp_options_id.startswith("dopt-")
           - result.vpc.id.startswith("vpc-")
           - '"instance_tenancy" in result.vpc'
@@ -158,7 +157,6 @@
           - result.vpc.cidr_block_association_set[0].association_id.startswith("vpc-cidr-assoc-")
           - result.vpc.cidr_block_association_set[0].cidr_block == vpc_cidr
           - result.vpc.cidr_block_association_set[0].cidr_block_state.state in ["associated", "associating"]
-          - '"classic_link_enabled" in result.vpc'
           - result.vpc.dhcp_options_id.startswith("dopt-")
           - result.vpc.id.startswith("vpc-")
           - '"instance_tenancy" in result.vpc'
@@ -216,8 +214,6 @@
           - vpc_info.vpcs[0].cidr_block_association_set[0].association_id == result.vpc.cidr_block_association_set[0].association_id
           - vpc_info.vpcs[0].cidr_block_association_set[0].cidr_block == result.vpc.cidr_block_association_set[0].cidr_block
           - vpc_info.vpcs[0].cidr_block_association_set[0].cidr_block_state.state in ["associated", "associating"]
-          - '"classic_link_dns_supported" in vpc_info.vpcs[0]'
-          - '"classic_link_enabled" in vpc_info.vpcs[0]'
           - vpc_info.vpcs[0].dhcp_options_id == result.vpc.dhcp_options_id
           - ( vpc_info.vpcs[0].enable_dns_hostnames | bool ) == True
           - ( vpc_info.vpcs[0].enable_dns_support | bool ) == True
@@ -323,8 +319,6 @@
           - vpc_info.vpcs[0].cidr_block_association_set[0].association_id == result.vpc.cidr_block_association_set[0].association_id
           - vpc_info.vpcs[0].cidr_block_association_set[0].cidr_block == result.vpc.cidr_block_association_set[0].cidr_block
           - vpc_info.vpcs[0].cidr_block_association_set[0].cidr_block_state.state in ["associated", "associating"]
-          - '"classic_link_dns_supported" in vpc_info.vpcs[0]'
-          - '"classic_link_enabled" in vpc_info.vpcs[0]'
           - vpc_info.vpcs[0].dhcp_options_id == result.vpc.dhcp_options_id
           - ( vpc_info.vpcs[0].enable_dns_hostnames | bool ) == True
           - ( vpc_info.vpcs[0].enable_dns_support | bool ) == True
@@ -384,7 +378,6 @@
           - result.vpc.cidr_block_association_set[0].association_id.startswith("vpc-cidr-assoc-")
           - result.vpc.cidr_block_association_set[0].cidr_block == vpc_cidr
           - result.vpc.cidr_block_association_set[0].cidr_block_state.state in ["associated", "associating"]
-          - '"classic_link_enabled" in result.vpc'
           - result.vpc.dhcp_options_id.startswith("dopt-")
           - '"instance_tenancy" in result.vpc'
           - result.vpc.ipv6_cidr_block_association_set | length == 1