getmoto / moto

A library that allows you to easily mock out tests based on AWS infrastructure.
http://docs.getmoto.org/en/latest/
Apache License 2.0
7.66k stars 2.05k forks source link

Mocking EC2 VPC Endpoint Create #8245

Closed sansns closed 3 weeks ago

sansns commented 3 weeks ago

Reporting Bugs

Setting the response from create_vpc_endpoint to a variable

        vpc_endpoint = ec2_client.create_vpc_endpoint(
            VpcId=vpc["VpcId"],
            ServiceName="com.amazonaws.vpce.us-east-1.ssmmessages",
            RouteTableIds=[route_table["RouteTableId"]],
            SubnetIds=[subnet_one["SubnetId"], subnet_two["SubnetId"]],
            VpcEndpointType="Interface",
        )["VpcEndpoint"]

Return the variable and try to return VPCEndpointID fails.

Return the VPCEndpointID in the ec2.create_vpc_endpoint response. This should return the VPCEndpointID instead of an error as it has not been set.

When trying to return VPCEndpointID it throws an error as the response does not have it set.

Moto Response: https://github.com/getmoto/moto/blob/d0db30178408597f9130b3fe0b05b1b1b2848004/moto/ec2/responses/vpcs.py#L197

Boto3 Response: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2/client/create_vpc_endpoint.html#create-vpc-endpoint

Moto 5.0.16 Boto3 1.35.29

If you do not provide all of these things, it will take us much longer to fix your problem.

bblommers commented 3 weeks ago

Hi @sansns, Moto does return that value! It has a lower case 'd' though - VpcEndpointId, instead of the VpcEndpointID that you've mentioned. Could that be the problem?

sansns commented 3 weeks ago

@bblommers - You are absolutely right, I fat fingered it and it did not work. Thank you for catching that.