Skip to content

[Bug] EIP updated on deployments #89

@alukach

Description

@alukach

Description of Bug:

For an unknown reason, a new EC2 instance and EIP is generated at each deployment.

This has the important negative effect of requiring us to update the bypassed IP address in the Vercel API.

Steps to Reproduce:

  1. Log into AWS, note the development us-east-1 environment EC2 instance id and its Elastic IP address
  2. Manually trigger deployment to development (https://github.com/source-cooperative/data.source.coop/actions/workflows/dev-deploy.yaml)
  3. After deployment complete, note different EC2 instance ID and Elastic IP address

Expected Behavior:

If the EC2 instance's properties aren't altered, there's no need for a new EC2 instance to be deployed.

Actual Behavior:

DataProxy-dev: start: Building DataProxy-dev Template
DataProxy-dev: success: Built DataProxy-dev Template
DataProxy-dev: start: Publishing DataProxy-dev Template (417712557820-us-east-1-71560aad)
DataProxy-dev: success: Published DataProxy-dev Template (417712557820-us-east-1-71560aad)
DataProxy-dev: deploying... [1/1]
DataProxy-dev: creating CloudFormation changeset...
DataProxy-dev | 0/7 | 11:27:40 PM | UPDATE_IN_PROGRESS   | AWS::CloudFormation::Stack                    | DataProxy-dev User Initiated
DataProxy-dev | 0/7 | 11:27:45 PM | UPDATE_IN_PROGRESS   | AWS::ECS::Cluster                             | source-data-proxy/cluster (sourcedataproxycluster2EC137A2) 
DataProxy-dev | 0/7 | 11:27:45 PM | UPDATE_IN_PROGRESS   | AWS::CDK::Metadata                            | CDKMetadata/Default (CDKMetadata) 
DataProxy-dev | 1/7 | 11:27:46 PM | UPDATE_COMPLETE      | AWS::CDK::Metadata                            | CDKMetadata/Default (CDKMetadata) 
DataProxy-dev | 1/7 | 11:27:46 PM | UPDATE_IN_PROGRESS   | AWS::EC2::Instance                            | vercel-api-proxy/squid-proxy (vercelapiproxysquidproxy8D06990C) Requested update requires the creation of a new physical resource; hence creating one.
DataProxy-dev | 2/7 | 11:27:47 PM | UPDATE_COMPLETE      | AWS::ECS::Cluster                             | source-data-proxy/cluster (sourcedataproxycluster2EC137A2) 
DataProxy-dev | 2/7 | 11:27:48 PM | UPDATE_IN_PROGRESS   | AWS::EC2::Instance                            | vercel-api-proxy/squid-proxy (vercelapiproxysquidproxy8D06990C) Resource creation Initiated
DataProxy-dev | 3/7 | 11:27:58 PM | UPDATE_COMPLETE      | AWS::EC2::Instance                            | vercel-api-proxy/squid-proxy (vercelapiproxysquidproxy8D06990C) 
DataProxy-dev | 3/7 | 11:28:00 PM | UPDATE_IN_PROGRESS   | AWS::EC2::EIPAssociation                      | vercel-api-proxy/proxy-eip-assoc (vercelapiproxyproxyeipassoc901196F9) 
DataProxy-dev | 3/7 | 11:28:01 PM | UPDATE_IN_PROGRESS   | AWS::Route53::RecordSet                       | vercel-api-proxy/proxy-a-record (vercelapiproxyproxyarecord4599A561) 
DataProxy-dev | 3/7 | 11:28:02 PM | DELETE_IN_PROGRESS   | AWS::EC2::EIPAssociation                      | vercel-api-proxy/proxy-eip-assoc (vercelapiproxyproxyeipassoc901196F9) Requested update requires the replacement of the existing resource; deleting existing resource, then creating a new one.
DataProxy-dev | 4/7 | 11:28:04 PM | DELETE_COMPLETE      | AWS::EC2::EIPAssociation                      | vercel-api-proxy/proxy-eip-assoc (vercelapiproxyproxyeipassoc901196F9) Resource eipassoc-0025f2d6b1f477e74 delete complete
DataProxy-dev | 4/7 | 11:28:08 PM | CREATE_IN_PROGRESS   | AWS::EC2::EIPAssociation                      | vercel-api-proxy/proxy-eip-assoc (vercelapiproxyproxyeipassoc901196F9) Resource creation Initiated
DataProxy-dev | 3/7 | 11:28:08 PM | CREATE_COMPLETE      | AWS::EC2::EIPAssociation                      | vercel-api-proxy/proxy-eip-assoc (vercelapiproxyproxyeipassoc901196F9) 
DataProxy-dev | 2/7 | 11:28:09 PM | UPDATE_COMPLETE      | AWS::EC2::EIPAssociation                      | vercel-api-proxy/proxy-eip-assoc (vercelapiproxyproxyeipassoc901196F9) 
DataProxy-dev | 3/7 | 11:28:12 PM | UPDATE_COMPLETE      | AWS::Route53::RecordSet                       | vercel-api-proxy/proxy-a-record (vercelapiproxyproxyarecord4599A561) 
DataProxy-dev | 4/7 | 11:28:13 PM | UPDATE_COMPLETE_CLEA | AWS::CloudFormation::Stack                    | DataProxy-dev 
DataProxy-dev | 4/7 | 11:28:15 PM | DELETE_IN_PROGRESS   | AWS::EC2::Instance                            | vercel-api-proxy/squid-proxy (vercelapiproxysquidproxy8D06990C) 
DataProxy-dev | 3/7 | 11:29:21 PM | DELETE_COMPLETE      | AWS::EC2::Instance                            | vercel-api-proxy/squid-proxy (vercelapiproxysquidproxy8D06990C) 
DataProxy-dev | 4/7 | 11:29:21 PM | UPDATE_COMPLETE      | AWS::CloudFormation::Stack                    | DataProxy-dev 

 ✅  DataProxy-dev

Screenshots:

Additional Context:

// Launch EC2 instance
const instance = new ec2.Instance(this, "squid-proxy", {
vpc: props.vpc,
role: ssmRole,
instanceType: ec2.InstanceType.of(
ec2.InstanceClass.T3,
ec2.InstanceSize.MICRO
),
machineImage: ec2.MachineImage.latestAmazonLinux2023(),
vpcSubnets: { subnetType: ec2.SubnetType.PUBLIC },
securityGroup: proxySg,
userData,
});
// Allocate and associate Elastic IP
const eip = new ec2.CfnEIP(this, "proxy-eip", {
domain: "vpc",
tags: [
{
key: "Name",
value: `${cdk.Stack.of(this).stackName}-proxy-eip`,
},
],
});
new ec2.CfnEIPAssociation(this, "proxy-eip-assoc", {
allocationId: eip.attrAllocationId,
instanceId: instance.instanceId,
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions