Skip to content

Commit

Permalink
remove commented original function
Browse files Browse the repository at this point in the history
  • Loading branch information
mandar242 committed Oct 17, 2024
1 parent 9e92be2 commit 4e09443
Showing 1 changed file with 0 additions and 81 deletions.
81 changes: 0 additions & 81 deletions plugins/modules/ec2_vpc_vgw.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,87 +351,6 @@ def find_vgw(
return sorted(response, key=lambda k: k["VpnGatewayId"])


# def ensure_vgw_present(client, module: AnsibleAWSModule) -> Tuple[bool, Dict[str, Any]]:
# # If an existing vgw name and type matches our args, then a match is considered to have been
# # found and we will not create another vgw.

# changed = False
# params = dict()
# result = dict()
# params["Name"] = module.params.get("name")
# params["VpcId"] = module.params.get("vpc_id")
# params["Type"] = module.params.get("type")
# params["Tags"] = module.params.get("tags")
# params["VpnGatewayIds"] = module.params.get("vpn_gateway_id")

# # check that the vpc_id exists. If not, an exception is thrown
# if params["VpcId"]:
# vpc = find_vpc(client, module)

# # check if a gateway matching our module args already exists
# existing_vgw = find_vgw(client, module)

# if existing_vgw != []:
# vpn_gateway_id = existing_vgw[0]["VpnGatewayId"]
# desired_tags = module.params.get("tags")
# purge_tags = module.params.get("purge_tags")
# if desired_tags is None:
# desired_tags = dict()
# purge_tags = False
# tags = dict(Name=module.params.get("name"))
# tags.update(desired_tags)
# changed = ensure_ec2_tags(
# client, module, vpn_gateway_id, resource_type="vpn-gateway", tags=tags, purge_tags=purge_tags
# )

# # if a vpc_id was provided, check if it exists and if it's attached
# if params["VpcId"]:
# current_vpc_attachments = existing_vgw[0]["VpcAttachments"]

# if current_vpc_attachments != [] and current_vpc_attachments[0]["State"] == "attached":
# if (
# current_vpc_attachments[0]["VpcId"] != params["VpcId"]
# or current_vpc_attachments[0]["State"] != "attached"
# ):
# # detach the existing vpc from the virtual gateway
# vpc_to_detach = current_vpc_attachments[0]["VpcId"]
# detach_vgw(client, module, vpn_gateway_id, vpc_to_detach)
# get_waiter(client, "vpn_gateway_detached").wait(VpnGatewayIds=[vpn_gateway_id])
# attached_vgw = attach_vgw(client, module, vpn_gateway_id)
# changed = True
# else:
# # attach the vgw to the supplied vpc
# attached_vgw = attach_vgw(client, module, vpn_gateway_id)
# changed = True

# # if params['VpcId'] is not provided, check the vgw is attached to a vpc. if so, detach it.
# else:
# existing_vgw = find_vgw(client, module, [vpn_gateway_id])

# if existing_vgw[0]["VpcAttachments"] != []:
# if existing_vgw[0]["VpcAttachments"][0]["State"] == "attached":
# # detach the vpc from the vgw
# vpc_to_detach = existing_vgw[0]["VpcAttachments"][0]["VpcId"]
# detach_vgw(client, module, vpn_gateway_id, vpc_to_detach)
# changed = True

# else:
# # create a new vgw
# new_vgw = create_vgw(client, module)
# changed = True
# vpn_gateway_id = new_vgw["VpnGatewayId"]

# # if a vpc-id was supplied, attempt to attach it to the vgw
# if params["VpcId"]:
# attached_vgw = attach_vgw(client, module, vpn_gateway_id)
# changed = True

# # return current state of the vgw
# vgw = find_vgw(client, module, [vpn_gateway_id])
# result = get_vgw_info(vgw)
# return changed, result


def ensure_vgw_present(client, module: AnsibleAWSModule) -> Tuple[bool, Dict[str, Any]]:
changed = False
params = {
Expand Down

0 comments on commit 4e09443

Please sign in to comment.