4365 cannot create listener (#4373)
This commit is contained in:
parent
d8f3d3f3e1
commit
71b4b47523
@ -872,7 +872,9 @@ CREATE_LISTENER_TEMPLATE = """<CreateListenerResponse xmlns="http://elasticloadb
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</Certificates>
|
</Certificates>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if listener.port %}
|
||||||
<Port>{{ listener.port }}</Port>
|
<Port>{{ listener.port }}</Port>
|
||||||
|
{% endif %}
|
||||||
<SslPolicy>{{ listener.ssl_policy }}</SslPolicy>
|
<SslPolicy>{{ listener.ssl_policy }}</SslPolicy>
|
||||||
<ListenerArn>{{ listener.arn }}</ListenerArn>
|
<ListenerArn>{{ listener.arn }}</ListenerArn>
|
||||||
<DefaultActions>
|
<DefaultActions>
|
||||||
|
@ -16,6 +16,31 @@ from tests import EXAMPLE_AMI_ID
|
|||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_create_load_balancer():
|
def test_create_load_balancer():
|
||||||
|
response, vpc, security_group, subnet1, subnet2, conn = create_load_balancer()
|
||||||
|
|
||||||
|
lb = response.get("LoadBalancers")[0]
|
||||||
|
VPCID = vpc.id
|
||||||
|
lb.get("DNSName").should.equal("my-lb-1.us-east-1.elb.amazonaws.com")
|
||||||
|
lb.get("LoadBalancerArn").should.equal(
|
||||||
|
"arn:aws:elasticloadbalancing:us-east-1:1:loadbalancer/my-lb/50dc6c495c0c9188"
|
||||||
|
)
|
||||||
|
lb.get("SecurityGroups").should.equal([security_group.id])
|
||||||
|
lb.get("AvailabilityZones").should.equal(
|
||||||
|
[
|
||||||
|
{"SubnetId": subnet1.id, "ZoneName": "us-east-1a"},
|
||||||
|
{"SubnetId": subnet2.id, "ZoneName": "us-east-1b"},
|
||||||
|
]
|
||||||
|
)
|
||||||
|
lb.get("CreatedTime").tzinfo.should_not.be.none
|
||||||
|
lb.get("State").get("Code").should.equal("provisioning")
|
||||||
|
|
||||||
|
# Ensure the tags persisted
|
||||||
|
response = conn.describe_tags(ResourceArns=[lb.get("LoadBalancerArn")])
|
||||||
|
tags = {d["Key"]: d["Value"] for d in response["TagDescriptions"][0]["Tags"]}
|
||||||
|
tags.should.equal({"key_name": "a_value"})
|
||||||
|
|
||||||
|
|
||||||
|
def create_load_balancer():
|
||||||
conn = boto3.client("elbv2", region_name="us-east-1")
|
conn = boto3.client("elbv2", region_name="us-east-1")
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
||||||
|
|
||||||
@ -37,53 +62,13 @@ def test_create_load_balancer():
|
|||||||
Scheme="internal",
|
Scheme="internal",
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
||||||
)
|
)
|
||||||
|
return response, vpc, security_group, subnet1, subnet2, conn
|
||||||
lb = response.get("LoadBalancers")[0]
|
|
||||||
|
|
||||||
lb.get("DNSName").should.equal("my-lb-1.us-east-1.elb.amazonaws.com")
|
|
||||||
lb.get("LoadBalancerArn").should.equal(
|
|
||||||
"arn:aws:elasticloadbalancing:us-east-1:1:loadbalancer/my-lb/50dc6c495c0c9188"
|
|
||||||
)
|
|
||||||
lb.get("SecurityGroups").should.equal([security_group.id])
|
|
||||||
lb.get("AvailabilityZones").should.equal(
|
|
||||||
[
|
|
||||||
{"SubnetId": subnet1.id, "ZoneName": "us-east-1a"},
|
|
||||||
{"SubnetId": subnet2.id, "ZoneName": "us-east-1b"},
|
|
||||||
]
|
|
||||||
)
|
|
||||||
lb.get("CreatedTime").tzinfo.should_not.be.none
|
|
||||||
lb.get("State").get("Code").should.equal("provisioning")
|
|
||||||
|
|
||||||
# Ensure the tags persisted
|
|
||||||
response = conn.describe_tags(ResourceArns=[lb.get("LoadBalancerArn")])
|
|
||||||
tags = {d["Key"]: d["Value"] for d in response["TagDescriptions"][0]["Tags"]}
|
|
||||||
tags.should.equal({"key_name": "a_value"})
|
|
||||||
|
|
||||||
|
|
||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_describe_load_balancers():
|
def test_describe_load_balancers():
|
||||||
conn = boto3.client("elbv2", region_name="us-east-1")
|
response, vpc, security_group, subnet1, subnet2, conn = create_load_balancer()
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
|
||||||
|
|
||||||
security_group = ec2.create_security_group(
|
|
||||||
GroupName="a-security-group", Description="First One"
|
|
||||||
)
|
|
||||||
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
|
|
||||||
subnet1 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.192/26", AvailabilityZone="us-east-1a"
|
|
||||||
)
|
|
||||||
subnet2 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.0/26", AvailabilityZone="us-east-1b"
|
|
||||||
)
|
|
||||||
|
|
||||||
conn.create_load_balancer(
|
|
||||||
Name="my-lb",
|
|
||||||
Subnets=[subnet1.id, subnet2.id],
|
|
||||||
SecurityGroups=[security_group.id],
|
|
||||||
Scheme="internal",
|
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
|
||||||
)
|
|
||||||
|
|
||||||
response = conn.describe_load_balancers()
|
response = conn.describe_load_balancers()
|
||||||
|
|
||||||
@ -109,28 +94,7 @@ def test_describe_load_balancers():
|
|||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_add_remove_tags():
|
def test_add_remove_tags():
|
||||||
conn = boto3.client("elbv2", region_name="us-east-1")
|
response, vpc, security_group, subnet1, subnet2, conn = create_load_balancer()
|
||||||
|
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
|
||||||
|
|
||||||
security_group = ec2.create_security_group(
|
|
||||||
GroupName="a-security-group", Description="First One"
|
|
||||||
)
|
|
||||||
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
|
|
||||||
subnet1 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.0/26", AvailabilityZone="us-east-1a"
|
|
||||||
)
|
|
||||||
subnet2 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.192/26", AvailabilityZone="us-east-1b"
|
|
||||||
)
|
|
||||||
|
|
||||||
conn.create_load_balancer(
|
|
||||||
Name="my-lb",
|
|
||||||
Subnets=[subnet1.id, subnet2.id],
|
|
||||||
SecurityGroups=[security_group.id],
|
|
||||||
Scheme="internal",
|
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
|
||||||
)
|
|
||||||
|
|
||||||
lbs = conn.describe_load_balancers()["LoadBalancers"]
|
lbs = conn.describe_load_balancers()["LoadBalancers"]
|
||||||
lbs.should.have.length_of(1)
|
lbs.should.have.length_of(1)
|
||||||
@ -250,30 +214,45 @@ def test_create_elb_in_multiple_region():
|
|||||||
).should.have.length_of(1)
|
).should.have.length_of(1)
|
||||||
|
|
||||||
|
|
||||||
|
@mock_elbv2
|
||||||
|
@mock_ec2
|
||||||
|
def test_create_listeners_without_port():
|
||||||
|
response, vpc, security_group, subnet1, subnet2, conn = create_load_balancer()
|
||||||
|
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
||||||
|
response = conn.create_target_group(
|
||||||
|
Name="a-target",
|
||||||
|
Protocol="HTTP",
|
||||||
|
Port=8080,
|
||||||
|
VpcId=vpc.id,
|
||||||
|
HealthCheckProtocol="HTTP",
|
||||||
|
HealthCheckPort="8080",
|
||||||
|
HealthCheckPath="/",
|
||||||
|
HealthCheckIntervalSeconds=5,
|
||||||
|
HealthCheckTimeoutSeconds=5,
|
||||||
|
HealthyThresholdCount=5,
|
||||||
|
UnhealthyThresholdCount=2,
|
||||||
|
Matcher={"HttpCode": "200"},
|
||||||
|
)
|
||||||
|
target_group = response.get("TargetGroups")[0]
|
||||||
|
target_group_arn = target_group["TargetGroupArn"]
|
||||||
|
response = conn.create_listener(
|
||||||
|
LoadBalancerArn=load_balancer_arn,
|
||||||
|
Protocol="HTTP",
|
||||||
|
DefaultActions=[{"Type": "forward", "TargetGroupArn": target_group_arn}],
|
||||||
|
)
|
||||||
|
|
||||||
|
listener = response.get("Listeners")[0]
|
||||||
|
listener.get("Port").should.equal(None)
|
||||||
|
listener.get("Protocol").should.equal("HTTP")
|
||||||
|
listener.get("DefaultActions").should.equal(
|
||||||
|
[{"TargetGroupArn": target_group_arn, "Type": "forward"}]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_create_target_group_and_listeners():
|
def test_create_target_group_and_listeners():
|
||||||
conn = boto3.client("elbv2", region_name="us-east-1")
|
response, vpc, security_group, subnet1, subnet2, conn = create_load_balancer()
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
|
||||||
|
|
||||||
security_group = ec2.create_security_group(
|
|
||||||
GroupName="a-security-group", Description="First One"
|
|
||||||
)
|
|
||||||
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
|
|
||||||
subnet1 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.192/26", AvailabilityZone="us-east-1a"
|
|
||||||
)
|
|
||||||
subnet2 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.0/26", AvailabilityZone="us-east-1b"
|
|
||||||
)
|
|
||||||
|
|
||||||
response = conn.create_load_balancer(
|
|
||||||
Name="my-lb",
|
|
||||||
Subnets=[subnet1.id, subnet2.id],
|
|
||||||
SecurityGroups=[security_group.id],
|
|
||||||
Scheme="internal",
|
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
|
||||||
)
|
|
||||||
|
|
||||||
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
||||||
|
|
||||||
@ -439,27 +418,7 @@ def test_create_target_group_and_listeners():
|
|||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_create_target_group_without_non_required_parameters():
|
def test_create_target_group_without_non_required_parameters():
|
||||||
conn = boto3.client("elbv2", region_name="us-east-1")
|
response, vpc, security_group, subnet1, subnet2, conn = create_load_balancer()
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
|
||||||
|
|
||||||
security_group = ec2.create_security_group(
|
|
||||||
GroupName="a-security-group", Description="First One"
|
|
||||||
)
|
|
||||||
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
|
|
||||||
subnet1 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.192/26", AvailabilityZone="us-east-1a"
|
|
||||||
)
|
|
||||||
subnet2 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.0/26", AvailabilityZone="us-east-1b"
|
|
||||||
)
|
|
||||||
|
|
||||||
response = conn.create_load_balancer(
|
|
||||||
Name="my-lb",
|
|
||||||
Subnets=[subnet1.id, subnet2.id],
|
|
||||||
SecurityGroups=[security_group.id],
|
|
||||||
Scheme="internal",
|
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
|
||||||
)
|
|
||||||
|
|
||||||
# request without HealthCheckIntervalSeconds parameter
|
# request without HealthCheckIntervalSeconds parameter
|
||||||
# which is default to 30 seconds
|
# which is default to 30 seconds
|
||||||
@ -574,27 +533,7 @@ def test_describe_paginated_balancers():
|
|||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_delete_load_balancer():
|
def test_delete_load_balancer():
|
||||||
conn = boto3.client("elbv2", region_name="us-east-1")
|
response, vpc, security_group, subnet1, subnet2, conn = create_load_balancer()
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
|
||||||
|
|
||||||
security_group = ec2.create_security_group(
|
|
||||||
GroupName="a-security-group", Description="First One"
|
|
||||||
)
|
|
||||||
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
|
|
||||||
subnet1 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.192/26", AvailabilityZone="us-east-1a"
|
|
||||||
)
|
|
||||||
subnet2 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.0/26", AvailabilityZone="us-east-1b"
|
|
||||||
)
|
|
||||||
|
|
||||||
response = conn.create_load_balancer(
|
|
||||||
Name="my-lb",
|
|
||||||
Subnets=[subnet1.id, subnet2.id],
|
|
||||||
SecurityGroups=[security_group.id],
|
|
||||||
Scheme="internal",
|
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
|
||||||
)
|
|
||||||
|
|
||||||
response.get("LoadBalancers").should.have.length_of(1)
|
response.get("LoadBalancers").should.have.length_of(1)
|
||||||
lb = response.get("LoadBalancers")[0]
|
lb = response.get("LoadBalancers")[0]
|
||||||
@ -842,27 +781,7 @@ def test_terminated_instance_target():
|
|||||||
@mock_ec2
|
@mock_ec2
|
||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
def test_target_group_attributes():
|
def test_target_group_attributes():
|
||||||
conn = boto3.client("elbv2", region_name="us-east-1")
|
response, vpc, security_group, subnet1, subnet2, conn = create_load_balancer()
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
|
||||||
|
|
||||||
security_group = ec2.create_security_group(
|
|
||||||
GroupName="a-security-group", Description="First One"
|
|
||||||
)
|
|
||||||
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
|
|
||||||
subnet1 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.192/26", AvailabilityZone="us-east-1a"
|
|
||||||
)
|
|
||||||
subnet2 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.0/26", AvailabilityZone="us-east-1b"
|
|
||||||
)
|
|
||||||
|
|
||||||
response = conn.create_load_balancer(
|
|
||||||
Name="my-lb",
|
|
||||||
Subnets=[subnet1.id, subnet2.id],
|
|
||||||
SecurityGroups=[security_group.id],
|
|
||||||
Scheme="internal",
|
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
|
||||||
)
|
|
||||||
|
|
||||||
response = conn.create_target_group(
|
response = conn.create_target_group(
|
||||||
Name="a-target",
|
Name="a-target",
|
||||||
@ -955,27 +874,7 @@ def test_create_target_group_invalid_protocol():
|
|||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_create_rule_priority_in_use():
|
def test_create_rule_priority_in_use():
|
||||||
elbv2 = boto3.client("elbv2", region_name="us-east-1")
|
response, vpc, security_group, subnet1, subnet2, elbv2 = create_load_balancer()
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
|
||||||
|
|
||||||
security_group = ec2.create_security_group(
|
|
||||||
GroupName="a-security-group", Description="First One"
|
|
||||||
)
|
|
||||||
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
|
|
||||||
subnet1 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.192/26", AvailabilityZone="us-east-1a"
|
|
||||||
)
|
|
||||||
subnet2 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.0/26", AvailabilityZone="us-east-1b"
|
|
||||||
)
|
|
||||||
|
|
||||||
response = elbv2.create_load_balancer(
|
|
||||||
Name="my-lb",
|
|
||||||
Subnets=[subnet1.id, subnet2.id],
|
|
||||||
SecurityGroups=[security_group.id],
|
|
||||||
Scheme="internal",
|
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
|
||||||
)
|
|
||||||
|
|
||||||
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
||||||
|
|
||||||
@ -1002,27 +901,7 @@ def test_create_rule_priority_in_use():
|
|||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_handle_listener_rules():
|
def test_handle_listener_rules():
|
||||||
conn = boto3.client("elbv2", region_name="us-east-1")
|
response, vpc, security_group, subnet1, subnet2, conn = create_load_balancer()
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
|
||||||
|
|
||||||
security_group = ec2.create_security_group(
|
|
||||||
GroupName="a-security-group", Description="First One"
|
|
||||||
)
|
|
||||||
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
|
|
||||||
subnet1 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.192/26", AvailabilityZone="us-east-1a"
|
|
||||||
)
|
|
||||||
subnet2 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.0/26", AvailabilityZone="us-east-1b"
|
|
||||||
)
|
|
||||||
|
|
||||||
response = conn.create_load_balancer(
|
|
||||||
Name="my-lb",
|
|
||||||
Subnets=[subnet1.id, subnet2.id],
|
|
||||||
SecurityGroups=[security_group.id],
|
|
||||||
Scheme="internal",
|
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
|
||||||
)
|
|
||||||
|
|
||||||
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
||||||
|
|
||||||
@ -1369,27 +1248,7 @@ def test_handle_listener_rules():
|
|||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_describe_invalid_target_group():
|
def test_describe_invalid_target_group():
|
||||||
conn = boto3.client("elbv2", region_name="us-east-1")
|
response, vpc, security_group, subnet1, subnet2, conn = create_load_balancer()
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
|
||||||
|
|
||||||
security_group = ec2.create_security_group(
|
|
||||||
GroupName="a-security-group", Description="First One"
|
|
||||||
)
|
|
||||||
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
|
|
||||||
subnet1 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.192/26", AvailabilityZone="us-east-1a"
|
|
||||||
)
|
|
||||||
subnet2 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.0/26", AvailabilityZone="us-east-1b"
|
|
||||||
)
|
|
||||||
|
|
||||||
response = conn.create_load_balancer(
|
|
||||||
Name="my-lb",
|
|
||||||
Subnets=[subnet1.id, subnet2.id],
|
|
||||||
SecurityGroups=[security_group.id],
|
|
||||||
Scheme="internal",
|
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
|
||||||
)
|
|
||||||
|
|
||||||
response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
||||||
|
|
||||||
@ -1416,27 +1275,7 @@ def test_describe_invalid_target_group():
|
|||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_describe_target_groups_no_arguments():
|
def test_describe_target_groups_no_arguments():
|
||||||
conn = boto3.client("elbv2", region_name="us-east-1")
|
response, vpc, security_group, subnet1, subnet2, conn = create_load_balancer()
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
|
||||||
|
|
||||||
security_group = ec2.create_security_group(
|
|
||||||
GroupName="a-security-group", Description="First One"
|
|
||||||
)
|
|
||||||
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
|
|
||||||
subnet1 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.192/26", AvailabilityZone="us-east-1a"
|
|
||||||
)
|
|
||||||
subnet2 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.0/26", AvailabilityZone="us-east-1b"
|
|
||||||
)
|
|
||||||
|
|
||||||
response = conn.create_load_balancer(
|
|
||||||
Name="my-lb",
|
|
||||||
Subnets=[subnet1.id, subnet2.id],
|
|
||||||
SecurityGroups=[security_group.id],
|
|
||||||
Scheme="internal",
|
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
|
||||||
)
|
|
||||||
|
|
||||||
response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
||||||
|
|
||||||
@ -1483,27 +1322,7 @@ def test_describe_ssl_policies():
|
|||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_set_ip_address_type():
|
def test_set_ip_address_type():
|
||||||
client = boto3.client("elbv2", region_name="us-east-1")
|
response, vpc, security_group, subnet1, subnet2, client = create_load_balancer()
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
|
||||||
|
|
||||||
security_group = ec2.create_security_group(
|
|
||||||
GroupName="a-security-group", Description="First One"
|
|
||||||
)
|
|
||||||
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
|
|
||||||
subnet1 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.192/26", AvailabilityZone="us-east-1a"
|
|
||||||
)
|
|
||||||
subnet2 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.0/26", AvailabilityZone="us-east-1b"
|
|
||||||
)
|
|
||||||
|
|
||||||
response = client.create_load_balancer(
|
|
||||||
Name="my-lb",
|
|
||||||
Subnets=[subnet1.id, subnet2.id],
|
|
||||||
SecurityGroups=[security_group.id],
|
|
||||||
Scheme="internal",
|
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
|
||||||
)
|
|
||||||
arn = response["LoadBalancers"][0]["LoadBalancerArn"]
|
arn = response["LoadBalancers"][0]["LoadBalancerArn"]
|
||||||
|
|
||||||
# Internal LBs cant be dualstack yet
|
# Internal LBs cant be dualstack yet
|
||||||
@ -1617,27 +1436,7 @@ def test_set_subnets_errors():
|
|||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_modify_load_balancer_attributes_idle_timeout():
|
def test_modify_load_balancer_attributes_idle_timeout():
|
||||||
client = boto3.client("elbv2", region_name="us-east-1")
|
response, vpc, security_group, subnet1, subnet2, client = create_load_balancer()
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
|
||||||
|
|
||||||
security_group = ec2.create_security_group(
|
|
||||||
GroupName="a-security-group", Description="First One"
|
|
||||||
)
|
|
||||||
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
|
|
||||||
subnet1 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.192/26", AvailabilityZone="us-east-1a"
|
|
||||||
)
|
|
||||||
subnet2 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.0/26", AvailabilityZone="us-east-1b"
|
|
||||||
)
|
|
||||||
|
|
||||||
response = client.create_load_balancer(
|
|
||||||
Name="my-lb",
|
|
||||||
Subnets=[subnet1.id, subnet2.id],
|
|
||||||
SecurityGroups=[security_group.id],
|
|
||||||
Scheme="internal",
|
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
|
||||||
)
|
|
||||||
arn = response["LoadBalancers"][0]["LoadBalancerArn"]
|
arn = response["LoadBalancers"][0]["LoadBalancerArn"]
|
||||||
|
|
||||||
client.modify_load_balancer_attributes(
|
client.modify_load_balancer_attributes(
|
||||||
@ -1824,28 +1623,7 @@ def test_modify_listener_http_to_https():
|
|||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_redirect_action_listener_rule():
|
def test_redirect_action_listener_rule():
|
||||||
conn = boto3.client("elbv2", region_name="us-east-1")
|
response, vpc, security_group, subnet1, subnet2, conn = create_load_balancer()
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
|
||||||
|
|
||||||
security_group = ec2.create_security_group(
|
|
||||||
GroupName="a-security-group", Description="First One"
|
|
||||||
)
|
|
||||||
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
|
|
||||||
subnet1 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.192/26", AvailabilityZone="us-east-1a"
|
|
||||||
)
|
|
||||||
subnet2 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.128/26", AvailabilityZone="us-east-1b"
|
|
||||||
)
|
|
||||||
|
|
||||||
response = conn.create_load_balancer(
|
|
||||||
Name="my-lb",
|
|
||||||
Subnets=[subnet1.id, subnet2.id],
|
|
||||||
SecurityGroups=[security_group.id],
|
|
||||||
Scheme="internal",
|
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
|
||||||
)
|
|
||||||
|
|
||||||
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
||||||
|
|
||||||
action = {
|
action = {
|
||||||
@ -1903,27 +1681,7 @@ def test_redirect_action_listener_rule():
|
|||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_cognito_action_listener_rule():
|
def test_cognito_action_listener_rule():
|
||||||
conn = boto3.client("elbv2", region_name="us-east-1")
|
response, vpc, security_group, subnet1, subnet2, conn = create_load_balancer()
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
|
||||||
|
|
||||||
security_group = ec2.create_security_group(
|
|
||||||
GroupName="a-security-group", Description="First One"
|
|
||||||
)
|
|
||||||
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
|
|
||||||
subnet1 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.192/26", AvailabilityZone="us-east-1a"
|
|
||||||
)
|
|
||||||
subnet2 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.128/26", AvailabilityZone="us-east-1b"
|
|
||||||
)
|
|
||||||
|
|
||||||
response = conn.create_load_balancer(
|
|
||||||
Name="my-lb",
|
|
||||||
Subnets=[subnet1.id, subnet2.id],
|
|
||||||
SecurityGroups=[security_group.id],
|
|
||||||
Scheme="internal",
|
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
|
||||||
)
|
|
||||||
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
||||||
|
|
||||||
action = {
|
action = {
|
||||||
@ -1966,27 +1724,7 @@ def test_cognito_action_listener_rule():
|
|||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_fixed_response_action_listener_rule():
|
def test_fixed_response_action_listener_rule():
|
||||||
conn = boto3.client("elbv2", region_name="us-east-1")
|
response, vpc, security_group, subnet1, subnet2, conn = create_load_balancer()
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
|
||||||
|
|
||||||
security_group = ec2.create_security_group(
|
|
||||||
GroupName="a-security-group", Description="First One"
|
|
||||||
)
|
|
||||||
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
|
|
||||||
subnet1 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.192/26", AvailabilityZone="us-east-1a"
|
|
||||||
)
|
|
||||||
subnet2 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.128/26", AvailabilityZone="us-east-1b"
|
|
||||||
)
|
|
||||||
|
|
||||||
response = conn.create_load_balancer(
|
|
||||||
Name="my-lb",
|
|
||||||
Subnets=[subnet1.id, subnet2.id],
|
|
||||||
SecurityGroups=[security_group.id],
|
|
||||||
Scheme="internal",
|
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
|
||||||
)
|
|
||||||
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
||||||
|
|
||||||
action = {
|
action = {
|
||||||
@ -2027,27 +1765,7 @@ def test_fixed_response_action_listener_rule():
|
|||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_fixed_response_action_listener_rule_validates_status_code():
|
def test_fixed_response_action_listener_rule_validates_status_code():
|
||||||
conn = boto3.client("elbv2", region_name="us-east-1")
|
response, vpc, security_group, subnet1, subnet2, conn = create_load_balancer()
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
|
||||||
|
|
||||||
security_group = ec2.create_security_group(
|
|
||||||
GroupName="a-security-group", Description="First One"
|
|
||||||
)
|
|
||||||
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
|
|
||||||
subnet1 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.192/26", AvailabilityZone="us-east-1a"
|
|
||||||
)
|
|
||||||
subnet2 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.128/26", AvailabilityZone="us-east-1b"
|
|
||||||
)
|
|
||||||
|
|
||||||
response = conn.create_load_balancer(
|
|
||||||
Name="my-lb",
|
|
||||||
Subnets=[subnet1.id, subnet2.id],
|
|
||||||
SecurityGroups=[security_group.id],
|
|
||||||
Scheme="internal",
|
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
|
||||||
)
|
|
||||||
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
||||||
|
|
||||||
invalid_status_code_action = {
|
invalid_status_code_action = {
|
||||||
@ -2075,27 +1793,7 @@ def test_fixed_response_action_listener_rule_validates_status_code():
|
|||||||
@mock_elbv2
|
@mock_elbv2
|
||||||
@mock_ec2
|
@mock_ec2
|
||||||
def test_fixed_response_action_listener_rule_validates_content_type():
|
def test_fixed_response_action_listener_rule_validates_content_type():
|
||||||
conn = boto3.client("elbv2", region_name="us-east-1")
|
response, vpc, security_group, subnet1, subnet2, conn = create_load_balancer()
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
|
||||||
|
|
||||||
security_group = ec2.create_security_group(
|
|
||||||
GroupName="a-security-group", Description="First One"
|
|
||||||
)
|
|
||||||
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
|
|
||||||
subnet1 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.192/26", AvailabilityZone="us-east-1a"
|
|
||||||
)
|
|
||||||
subnet2 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.128/26", AvailabilityZone="us-east-1b"
|
|
||||||
)
|
|
||||||
|
|
||||||
response = conn.create_load_balancer(
|
|
||||||
Name="my-lb",
|
|
||||||
Subnets=[subnet1.id, subnet2.id],
|
|
||||||
SecurityGroups=[security_group.id],
|
|
||||||
Scheme="internal",
|
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
|
||||||
)
|
|
||||||
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
||||||
|
|
||||||
invalid_content_type_action = {
|
invalid_content_type_action = {
|
||||||
|
Loading…
Reference in New Issue
Block a user