diff --git a/moto/ec2/responses/vpcs.py b/moto/ec2/responses/vpcs.py index 86df332aa..bcd482567 100644 --- a/moto/ec2/responses/vpcs.py +++ b/moto/ec2/responses/vpcs.py @@ -50,7 +50,7 @@ CREATE_VPC_RESPONSE = """ {{ vpc.id }} pending {{ vpc.cidr_block }} - dopt-1a2b3c4d2 + {% if vpc.dhcp_options %}{{ vpc.dhcp_options.id }}{% else %}dopt-7a8b9c2d{% endif %} default {% for tag in vpc.get_tags() %} @@ -74,7 +74,7 @@ DESCRIBE_VPCS_RESPONSE = """ {{ vpc.id }} {{ vpc.state }} {{ vpc.cidr_block }} - dopt-7a8b9c2d + {% if vpc.dhcp_options %}{{ vpc.dhcp_options.id }}{% else %}dopt-7a8b9c2d{% endif %} default {{ vpc.is_default }} diff --git a/tests/test_ec2/test_vpcs.py b/tests/test_ec2/test_vpcs.py index 7860584e5..8349b8f6f 100644 --- a/tests/test_ec2/test_vpcs.py +++ b/tests/test_ec2/test_vpcs.py @@ -321,3 +321,14 @@ def test_vpc_modify_enable_dns_hostnames(): response = vpc.describe_attribute(Attribute='enableDnsHostnames') attr = response.get('EnableDnsHostnames') attr.get('Value').should.be.ok + +@mock_ec2 +def test_vpc_associate_dhcp_options(): + conn = boto.connect_vpc() + dhcp_options = conn.create_dhcp_options(SAMPLE_DOMAIN_NAME, SAMPLE_NAME_SERVERS) + vpc = conn.create_vpc("10.0.0.0/16") + + conn.associate_dhcp_options(dhcp_options.id, vpc.id) + + vpc.update() + dhcp_options.id.should.equal(vpc.dhcp_options_id)