feat(ec2): EC2 Instance Connect Endpoint control plane (#7359)

* feat(ec2): EC2 Instance Connect Endpoint control plane

CreateInstanceConnectEndpoint, DescribeInstanceConnectEndpoints and
DeleteInstanceConnectEndpoint answered UnknownOperation, so Terraform's
aws_ec2_instance_connect_endpoint failed at create and the AWS CLI's
`ec2-instance-connect ssh --connection-type eice` could not look an
endpoint up. They now carry the fields, filters and errors Terraform and
the CLI use. Endpoint DNS names are <id>.localhost.floci.io, which public
DNS resolves to 127.0.0.1, and each endpoint takes a private address in
its subnet.

As on AWS, a live endpoint makes DeleteSubnet and DeleteVpc fail with
DependencyViolation (a destroy ordered wrongly would otherwise pass here
and fail on AWS, and the endpoint's address reservation leaked), and a
replayed ClientToken returns the first endpoint instead of creating a
duplicate on an SDK or Terraform retry.

The tunnel the endpoint serves is a separate change.

* fix(ec2): create an EC2 Instance Connect Endpoint under the subnet topology lock

Two creates with one ClientToken could both miss the replay scan and make
two endpoints, and a DeleteSubnet could land between the subnet check and
the save, leaving an endpoint on a subnet that is gone. The create now
holds the lock DeleteSubnet holds. The endpoint store is final and comes
through the constructor chain like the other stores, and the service test
is named Ec2InstanceConnectEndpointServiceTest.

* test(ec2): name the exceptions the endpoint race test expects

* fix(ec2): return a copy from instance connect endpoint reads

Create, Describe and Delete handed back the stored endpoint itself, with
its tags written onto it, and Delete then set delete-in-progress on that
object. A caller changing a returned endpoint changed the stored one.
They now return a copy carrying the current tags.

* fix(ec2): scan one region's instance connect endpoints by key on describe

Describe read every region's endpoints and kept those whose region field
matched, while the ClientToken replay scan picks a region by store key.
Describe now uses the key prefix too, so the two agree on what is in a
region and describe no longer reads other regions' records.

* fix(ec2): compare every creation parameter on an instance connect endpoint ClientToken replay

A replayed ClientToken compared only SubnetId, so a retry with other
security groups, IpAddressType, PreserveClientIp or tags returned the
first endpoint as if it matched. Each is now compared after defaults are
applied and a difference is IdempotentParameterMismatch, as the egress-only
internet gateway create does. Tags are compared as the create request
carried them, so a later CreateTags does not turn a retry into a mismatch.

* test(ec2): drive instance connect endpoints over the EC2 Query wire

The service test called Ec2Service directly, so nothing covered the query
handler: SecurityGroupId.N and TagSpecification.N parsing, the ClientToken
echo, and the Create, Describe and Delete response envelopes. The
integration test creates, replays, describes and deletes an endpoint
through the HTTP endpoint and reads each result back with a separate
Describe.

* fix(ec2): validate instance connect endpoint requests before answering DryRun

CreateInstanceConnectEndpoint answered DryRunOperation before checking the
subnet, IpAddressType or security groups, and Describe and Delete ignored
DryRun and acted on the request. Create now validates and then answers
DryRunOperation, as RunInstances and ReplaceRoute do, and Describe and
Delete check the IDs and filters first, then answer DryRunOperation
without deleting anything.

* fix(ec2): page DescribeInstanceConnectEndpoints by MaxResults and NextToken

MaxResults and NextToken were ignored and every match came back on one
page. Describe now returns at most MaxResults endpoints in ID order with a
nextToken for the rest, using the shared opaque-cursor pagination, and an
unreadable NextToken is InvalidParameterValue as DescribeDhcpOptions
answers it. MaxResults is not range-checked against the model's 1-50.

* fix(ec2): range-check MaxResults on DescribeInstanceConnectEndpoints and compare replayed security groups as a set

The model's InstanceConnectEndpointMaxResults allows 1 to 50, but a sent
0, negative or larger value was served. It is now InvalidMaxResults, as
DescribeTags and DescribeEgressOnlyInternetGateways refuse values outside
their own ranges; an omitted MaxResults still returns every match.

A test now pins that a ClientToken replay naming the same security groups
in another order returns the first endpoint.

* docs(ec2): name instance connect endpoints among the private address holders

privateIpsInUse and privateIpsHeldOnVpcNetwork count the addresses EC2 Instance Connect Endpoints hold, but their comments listed only instances, network interfaces and NAT gateways.

* test(ec2): refuse a NAT gateway the private address an instance connect endpoint holds

CreateNatGateway with a PrivateIpAddress an EC2 Instance Connect Endpoint holds answers InvalidIPAddress.InUse, and the address is free again once the endpoint is deleted. Nothing covered the endpoint's share of the in-use scan before.

* fix(ec2): copy each creation tag of an instance connect endpoint

The copy constructor copied the creationTags list but shared its Tag
objects with the stored endpoint, and the create stored the request's
own Tag objects. Changing a tag on a returned endpoint, or on the list
passed to the create, changed the saved creation parameters, so a
retry with the same ClientToken and the original tags failed with
IdempotentParameterMismatch. Copy each Tag when saving and when
returning a copy.

* fix(ec2): reject an unknown DescribeInstanceConnectEndpoints filter before scanning

An unknown filter name was rejected only while testing it against an
endpoint, so with no endpoints, or when an earlier filter excluded them
all, the bad name succeeded silently. Check every name up front through
requireSupportedFilters, as DescribeVpcs and DescribeVpnGateways do,
with the same InvalidParameterValue.

* fix(ec2): resolve an instance connect endpoint's interface in DescribeNetworkInterfaces

CreateInstanceConnectEndpoint published an interface ID in
networkInterfaceIdSet that DescribeNetworkInterfaces answered with
InvalidNetworkInterfaceID.NotFound, so a client could not read the
endpoint's private address or security groups from it. Build the
interface from the endpoint in the describe path, as the NAT gateway
and interface VPC endpoint arms already do: a requester-managed
ec2_instance_connect_endpoint interface with the endpoint's subnet,
VPC, private address and security groups, present while the endpoint
exists. Its address is already counted from the endpoint record, so
subnet address accounting is unchanged. DeleteInstanceConnectEndpoint
also drops the interface's own tags, as DeleteNatGateway does.

* fix(ec2): name an instance connect endpoint interface's groups from the account it is read for

The explicit-account DescribeNetworkInterfaces overload scanned the
named account's endpoints but looked their security group names up
under the ambient request account, so a caller in another account got
the groups back without names. Read the group for the same account,
as natNetworkInterfacesOf reads its subnet.

* test(ec2): keep another account's instance connect endpoint interface out of DescribeNetworkInterfaces

An endpoint created in one account is NotFound by NetworkInterfaceId
and absent from an unfiltered list for another account, and still
visible to its own.

* fix(ec2): accept exactly AWS's DescribeInstanceConnectEndpoints filters

The DescribeInstanceConnectEndpoints reference lists instance-connect-endpoint-id,
state, subnet-id, tag:<key>, tag-key, tag-value and vpc-id. Implement tag-value
(any tag's value in the filter values, as the other EC2 describe calls match it)
and stop accepting availability-zone and owner-id, which the reference does not
list; they are now refused as InvalidParameterValue like any unknown filter.

* refactor(ec2): build NAT gateway and instance connect endpoint interfaces once

natNetworkInterfacesOf and instanceConnectEndpointNetworkInterfacesOf set up the
same requester-managed interface with one primary address; both now call
requesterManagedInterface. Their two DescribeNetworkInterfaces arms, identical
but for the interfaces they walk, become one arm over NAT interfaces then
endpoint interfaces, the order the two arms ran in. No behaviour change.

* test(ec2): share a mock-mode Ec2Service builder in the test fixtures

Ec2ServiceFixtures.mockModeService() in the shared testing package builds the
mock-mode Ec2Service over in-memory storage that Ec2InstanceConnectEndpointServiceTest
built privately, and that class now uses it. The other classes with their own copy
move to it separately.

* docs(ec2): count the three InstanceConnectEndpoint operations in the service matrix
This commit is contained in:
Allen Sanborn authored and GitHub committed 2026-11-03 23:25:57 -04:00
1 parent a98380b387
commit 196b672563
9 files changed
+1302 -52

No files matched your search

@@ -303,6 +303,9 @@ public class Ec2QueryHandler {
// NAT Gateways
case "CreateNatGateway" -> handleCreateNatGateway(params, region);
case "DescribeNatGateways" -> handleDescribeNatGateways(params, region);
case "CreateInstanceConnectEndpoint" -> handleCreateInstanceConnectEndpoint(params, region);
case "DescribeInstanceConnectEndpoints" -> handleDescribeInstanceConnectEndpoints(params, region);
case "DeleteInstanceConnectEndpoint" -> handleDeleteInstanceConnectEndpoint(params, region);
case "DeleteNatGateway" -> handleDeleteNatGateway(params, region);
// Capacity Reservations
case "CreateCapacityReservation" -> handleCreateCapacityReservation(params, region);
@@ -4512,6 +4515,96 @@ public class Ec2QueryHandler {
return xmlResponse(xml.build());
}
// ─── EC2 Instance Connect Endpoint handlers ───────────────────────────────
private Response handleCreateInstanceConnectEndpoint(MultivaluedMap<String, String> p, String region) {
String preserve = p.getFirst("PreserveClientIp");
// The service validates the request before answering a DryRun, as AWS does.
InstanceConnectEndpoint endpoint = service.createInstanceConnectEndpoint(region, p.getFirst("SubnetId"),
getList(p, "SecurityGroupId"), preserve == null ? null : Boolean.parseBoolean(preserve),
p.getFirst("IpAddressType"), parseTagsForResource(p, "instance-connect-endpoint"),
p.getFirst("ClientToken"), Boolean.parseBoolean(p.getFirst("DryRun")));
XmlBuilder xml = new XmlBuilder()
.start("CreateInstanceConnectEndpointResponse", AwsNamespaces.EC2)
.elem("requestId", UUID.randomUUID().toString())
.start("instanceConnectEndpoint").raw(instanceConnectEndpointXml(endpoint)).end("instanceConnectEndpoint")
.elem("clientToken", p.getFirst("ClientToken"))
.end("CreateInstanceConnectEndpointResponse");
return xmlResponse(xml.build());
}
private Response handleDescribeInstanceConnectEndpoints(MultivaluedMap<String, String> p, String region) {
String maxResults = p.getFirst("MaxResults");
PaginatedResult<InstanceConnectEndpoint> page = service.describeInstanceConnectEndpoints(region,
getList(p, "InstanceConnectEndpointId"), getFiltersList(p),
maxResults == null || maxResults.isEmpty() ? null : parseIntParam(p, "MaxResults", 0),
p.getFirst("NextToken"));
// After the describe, so an unknown ID, filter or NextToken fails on its own error first.
checkDryRun(p);
XmlBuilder xml = new XmlBuilder()
.start("DescribeInstanceConnectEndpointsResponse", AwsNamespaces.EC2)
.elem("requestId", UUID.randomUUID().toString())
.start("instanceConnectEndpointSet");
for (InstanceConnectEndpoint endpoint : page.items()) {
xml.start("item").raw(instanceConnectEndpointXml(endpoint)).end("item");
}
xml.end("instanceConnectEndpointSet");
if (page.nextToken() != null) {
xml.elem("nextToken", page.nextToken());
}
xml.end("DescribeInstanceConnectEndpointsResponse");
return xmlResponse(xml.build());
}
private Response handleDeleteInstanceConnectEndpoint(MultivaluedMap<String, String> p, String region) {
String id = p.getFirst("InstanceConnectEndpointId");
if (id == null || id.isBlank()) {
throw new AwsException("MissingParameter",
"The request must contain the parameter InstanceConnectEndpointId", 400);
}
service.describeInstanceConnectEndpoints(region, List.of(id), List.of());
checkDryRun(p);
InstanceConnectEndpoint endpoint = service.deleteInstanceConnectEndpoint(region, id);
XmlBuilder xml = new XmlBuilder()
.start("DeleteInstanceConnectEndpointResponse", AwsNamespaces.EC2)
.elem("requestId", UUID.randomUUID().toString())
.start("instanceConnectEndpoint").raw(instanceConnectEndpointXml(endpoint)).end("instanceConnectEndpoint")
.end("DeleteInstanceConnectEndpointResponse");
return xmlResponse(xml.build());
}
private String instanceConnectEndpointXml(InstanceConnectEndpoint endpoint) {
XmlBuilder xml = new XmlBuilder()
.elem("ownerId", endpoint.getOwnerId())
.elem("instanceConnectEndpointId", endpoint.getInstanceConnectEndpointId())
.elem("instanceConnectEndpointArn", endpoint.getInstanceConnectEndpointArn())
.elem("state", endpoint.getState())
.elem("stateMessage", "")
.elem("dnsName", endpoint.getDnsName())
.elem("fipsDnsName", endpoint.getFipsDnsName())
.start("networkInterfaceIdSet");
endpoint.getNetworkInterfaceIds().forEach(id -> xml.elem("item", id));
xml.end("networkInterfaceIdSet")
.elem("vpcId", endpoint.getVpcId())
.elem("availabilityZone", endpoint.getAvailabilityZone())
.elem("availabilityZoneId", endpoint.getAvailabilityZoneId())
.elem("createdAt", endpoint.getCreatedAt() == null ? null : ISO_FMT.format(endpoint.getCreatedAt()))
.elem("subnetId", endpoint.getSubnetId())
.elem("preserveClientIp", endpoint.isPreserveClientIp())
.start("securityGroupIdSet");
endpoint.getSecurityGroupIds().forEach(id -> xml.elem("item", id));
xml.end("securityGroupIdSet")
.elem("ipAddressType", endpoint.getIpAddressType())
.start("publicDnsNames")
.start("ipv4")
.elem("dnsName", endpoint.getDnsName())
.elem("fipsDnsName", endpoint.getFipsDnsName())
.end("ipv4")
.end("publicDnsNames");
xml.raw(tagSetXml(endpoint.getTags()));
return xml.build();
}
// ─── Capacity Reservation handlers ────────────────────────────────────────
private Response handleCreateCapacityReservation(MultivaluedMap<String, String> p, String region) {
@@ -12,6 +12,7 @@ import io.github.hectorvent.floci.core.common.AwsRegions;
import io.github.hectorvent.floci.core.common.CidrCanonicalizer;
import io.github.hectorvent.floci.core.common.ContainerTeardown;
import io.github.hectorvent.floci.core.common.PaginatedResult;
import io.github.hectorvent.floci.core.common.Pagination;
import io.github.hectorvent.floci.core.common.RequestContext;
import io.github.hectorvent.floci.core.common.RequestScopes;
import io.github.hectorvent.floci.core.common.Resettable;
@@ -37,6 +38,7 @@ import io.github.hectorvent.floci.services.ec2.model.Host;
import io.github.hectorvent.floci.services.ec2.model.IamInstanceProfileAssociation;
import io.github.hectorvent.floci.services.ec2.model.Image;
import io.github.hectorvent.floci.services.ec2.model.Instance;
import io.github.hectorvent.floci.services.ec2.model.InstanceConnectEndpoint;
import io.github.hectorvent.floci.services.ec2.model.InstanceCreditSpecification;
import io.github.hectorvent.floci.services.ec2.model.InstanceCreditSpecificationListResult;
import io.github.hectorvent.floci.services.ec2.model.InstanceNetworkInterface;
@@ -178,7 +180,7 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
private static final String TAGGABLE_RESOURCE_TYPES = "(cvpn-endpoint|subnet-cidr-assoc|vpc-cidr-assoc"
+ "|ipam-pool-alloc|ipam-scope|ipam-pool|ipam"
+ "|traf-mir-fil|traf-mir-tar|iip-assoc|eni-attach|tgw-attach|tgw-rtb|vpce-svc|aclassoc|eipassoc"
+ "|eipalloc|rtbassoc|subnet|fleet|cagw|dopt|eigw|snap|vpce|acl|ami|cgw|eni|igw|key|nat|pcx|rtb|scr"
+ "|eipalloc|rtbassoc|subnet|fleet|cagw|dopt|eice|eigw|snap|vpce|acl|ami|cgw|eni|igw|key|nat|pcx|rtb|scr"
+ "|sfr|sgr|sir|tgw|tms|vgw|vol|vpc|vpn|cr|fl|lt|pl|sg|h|i|r)-";
private static final Pattern TAGGABLE_RESOURCE_ID = Pattern.compile(TAGGABLE_RESOURCE_TYPES
+ "(?:[0-9a-f]{8,}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})");
@@ -304,6 +306,7 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
private final StorageBackend<String, LaunchTemplate> launchTemplates;
private final StorageBackend<String, VpcEndpoint> vpcEndpoints;
private final StorageBackend<String, NatGateway> natGateways;
private final StorageBackend<String, InstanceConnectEndpoint> instanceConnectEndpoints;
private final StorageBackend<String, SpotInstanceRequest> spotInstanceRequests;
private final StorageBackend<String, NetworkAcl> networkAcls;
private final StorageBackend<String, ManagedPrefixList> managedPrefixLists;
@@ -588,7 +591,9 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
storageFactory.create("ec2", "ec2-egress-only-internet-gateways.json",
new TypeReference<Map<String, EgressOnlyInternetGateway>>() {}),
storageFactory.create("ec2", "ec2-dhcp-options.json",
new TypeReference<Map<String, DhcpOptions>>() {}));
new TypeReference<Map<String, DhcpOptions>>() {}),
storageFactory.create("ec2", "ec2-instance-connect-endpoints.json",
new TypeReference<Map<String, InstanceConnectEndpoint>>() {}));
}
// Package-private for hermetic tests (pass in-memory or temp-dir-backed StorageBackends directly).
@@ -654,7 +659,7 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
new InMemoryStorage<>(), new InMemoryStorage<>(), new InMemoryStorage<>(),
null, null, null, new InMemoryStorage<>(), new InMemoryStorage<>(),
new InMemoryStorage<>(), dhcpOptions);
new InMemoryStorage<>(), dhcpOptions, AccountAwareStorageBackend.inMemory("000000000000"));
}
// Package-private for hermetic tests, transit-gateway-aware. The shorter overload above keeps its
@@ -881,7 +886,8 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
transitGatewayPropagations, transitGatewayRoutes, vpcPeeringConnections,
networkInterfaces, capacityReservations, volumeModifications,
requestContextInstance, iamService, volumeBlockDeviceManager, hosts,
transitGatewayPeeringAttachments, egressOnlyInternetGateways, new InMemoryStorage<>());
transitGatewayPeeringAttachments, egressOnlyInternetGateways, new InMemoryStorage<>(),
AccountAwareStorageBackend.inMemory("000000000000"));
}
Ec2Service(EmulatorConfig config, Ec2ContainerManager containerManager,
@@ -922,7 +928,9 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
StorageBackend<String, Host> hosts,
StorageBackend<String, TransitGatewayPeeringAttachment> transitGatewayPeeringAttachments,
StorageBackend<String, EgressOnlyInternetGateway> egressOnlyInternetGateways,
StorageBackend<String, DhcpOptions> dhcpOptions) {
StorageBackend<String, DhcpOptions> dhcpOptions,
StorageBackend<String, InstanceConnectEndpoint> instanceConnectEndpoints) {
this.instanceConnectEndpoints = instanceConnectEndpoints;
this.hosts = hosts;
this.egressOnlyInternetGateways = egressOnlyInternetGateways;
this.transitGatewayPeeringAttachments = transitGatewayPeeringAttachments;
@@ -4704,14 +4712,16 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
String regionPrefix = region + "::";
return privateIpsBySubnet(valuesOfEveryAccount(networkInterfaces, regionPrefix),
valuesOfEveryAccount(instances, regionPrefix),
valuesOfEveryAccount(natGateways, regionPrefix))
valuesOfEveryAccount(natGateways, regionPrefix),
valuesOfEveryAccount(instanceConnectEndpoints, regionPrefix))
.getOrDefault(subnetId, Set.of());
}
/**
* Every address a stored resource holds in the subnet: {@link #privateIpsTaken}, plus what the
* instances, network interfaces and NAT gateways of every account hold there. Default subnet
* ids are the same in every account, so their Docker network, and its lease table, is shared.
* instances, network interfaces, NAT gateways and EC2 Instance Connect Endpoints of every
* account hold there. Default subnet ids are the same in every account, so their Docker
* network, and its lease table, is shared.
*/
private Set<String> privateIpsHeldOnVpcNetwork(String region, String subnetId) {
Set<String> held = privateIpsTaken(region, subnetId);
@@ -4732,7 +4742,10 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
400);
}
/** Every private address a live instance, network interface or NAT gateway holds in the subnet. */
/**
* Every private address a live instance, network interface, NAT gateway or EC2 Instance Connect
* Endpoint holds in the subnet.
*/
private Set<String> privateIpsInUse(String region, String subnetId) {
return new HashSet<>(privateIpsBySubnet(region).getOrDefault(subnetId, Set.of()));
}
@@ -4752,12 +4765,14 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
String regionPrefix = region + "::";
return privateIpsBySubnet(networkInterfaces.scan(k -> k.startsWith(regionPrefix)),
instances.scan(k -> k.startsWith(regionPrefix)),
natGateways.scan(k -> k.startsWith(regionPrefix)));
natGateways.scan(k -> k.startsWith(regionPrefix)),
instanceConnectEndpoints.scan(k -> k.startsWith(regionPrefix)));
}
private static Map<String, Set<String>> privateIpsBySubnet(List<NetworkInterface> regionInterfaces,
List<Instance> regionInstances,
List<NatGateway> regionNatGateways) {
List<NatGateway> regionNatGateways,
List<InstanceConnectEndpoint> regionInstanceConnectEndpoints) {
Map<String, Set<String>> bySubnet = new HashMap<>();
for (NetworkInterface ni : regionInterfaces) {
Set<String> inUse = bySubnet.computeIfAbsent(ni.getSubnetId(), ignored -> new HashSet<>());
@@ -4778,6 +4793,10 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
ni.getPrivateIpAddress());
}
}
for (InstanceConnectEndpoint endpoint : regionInstanceConnectEndpoints) {
addIfSet(bySubnet.computeIfAbsent(endpoint.getSubnetId(), ignored -> new HashSet<>()),
endpoint.getPrivateIpAddress());
}
for (NatGateway natGateway : regionNatGateways) {
if ("deleted".equals(natGateway.getState())) {
continue;
@@ -6492,7 +6511,9 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
.anyMatch(ni -> subnetIds.contains(ni.getSubnetId()))
|| vpcEndpoints.scan(k -> k.startsWith(regionPrefix)).stream()
.anyMatch(endpoint -> !"deleted".equals(endpoint.getState())
&& nullToEmpty(endpoint.getSubnetIds()).stream().anyMatch(subnetIds::contains));
&& nullToEmpty(endpoint.getSubnetIds()).stream().anyMatch(subnetIds::contains))
|| instanceConnectEndpoints.scan(k -> k.startsWith(regionPrefix)).stream()
.anyMatch(endpoint -> subnetIds.contains(endpoint.getSubnetId()));
if (occupied) {
throw new AwsException("DependencyViolation", message, 400);
}
@@ -10259,6 +10280,7 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
case "nat" -> getRequiredNatGateway(region, resourceId);
case "eipalloc" -> getRequiredAddress(region, resourceId);
case "vpce" -> getRequiredVpcEndpoint(region, resourceId);
case "eice" -> requireInstanceConnectEndpoint(region, resourceId);
case "pl" -> getRequiredManagedPrefixList(region, resourceId);
case "tgw" -> getRequiredTransitGateway(region, resourceId);
case "tgw-rtb" -> getRequiredTransitGatewayRouteTable(region, resourceId);
@@ -12614,9 +12636,23 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
if (address.getNetworkInterfaceId() == null) {
continue;
}
NetworkInterfacePrivateIpAddress ip = new NetworkInterfacePrivateIpAddress();
ip.setPrivateIpAddress(address.getPrivateIp());
ip.setPrimary(address.isPrimary());
// A secondary address sits on the primary address's interface; the helper marks its one
// address primary, so a secondary is added to the interface it returned.
NetworkInterface ni = result.get(address.getNetworkInterfaceId());
NetworkInterfacePrivateIpAddress ip;
if (ni == null) {
ni = requesterManagedInterface(address.getNetworkInterfaceId(),
natGateway.getSubnetId(), natGateway.getVpcId(), subnet.getAvailabilityZone(),
"Interface for NAT Gateway " + natGateway.getNatGatewayId(), "nat_gateway", ownerId,
address.getPrivateIp());
ip = ni.getPrivateIpAddresses().getFirst();
result.put(address.getNetworkInterfaceId(), ni);
} else {
ip = new NetworkInterfacePrivateIpAddress();
ip.setPrivateIpAddress(address.getPrivateIp());
ip.setPrimary(address.isPrimary());
ni.getPrivateIpAddresses().add(ip);
}
if (address.getPublicIp() != null) {
NetworkInterfaceAssociation assoc = new NetworkInterfaceAssociation();
assoc.setPublicIp(address.getPublicIp());
@@ -12625,28 +12661,286 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
assoc.setIpOwnerId(ownerId);
ip.setAssociation(assoc);
}
// A secondary address sits on the primary address's interface.
NetworkInterface existing = result.get(address.getNetworkInterfaceId());
if (existing != null) {
existing.getPrivateIpAddresses().add(ip);
continue;
}
NetworkInterface ni = new NetworkInterface();
ni.setNetworkInterfaceId(address.getNetworkInterfaceId());
ni.setSubnetId(natGateway.getSubnetId());
ni.setVpcId(natGateway.getVpcId());
ni.setAvailabilityZone(subnet.getAvailabilityZone());
ni.setDescription("Interface for NAT Gateway " + natGateway.getNatGatewayId());
ni.setInterfaceType("nat_gateway");
ni.setRequesterManaged(true);
ni.setOwnerId(ownerId);
ni.setPrivateIpAddress(address.getPrivateIp());
ni.getPrivateIpAddresses().add(ip);
result.put(address.getNetworkInterfaceId(), ni);
}
return new ArrayList<>(result.values());
}
/**
* A requester-managed interface with one primary private address: the shape a NAT gateway's
* and an instance connect endpoint's interface share.
*/
private static NetworkInterface requesterManagedInterface(String eniId, String subnetId, String vpcId,
String availabilityZone, String description,
String interfaceType, String ownerId,
String privateIp) {
NetworkInterface ni = new NetworkInterface();
ni.setNetworkInterfaceId(eniId);
ni.setSubnetId(subnetId);
ni.setVpcId(vpcId);
ni.setAvailabilityZone(availabilityZone);
ni.setDescription(description);
ni.setInterfaceType(interfaceType);
ni.setRequesterManaged(true);
ni.setOwnerId(ownerId);
ni.setPrivateIpAddress(privateIp);
NetworkInterfacePrivateIpAddress primaryIp = new NetworkInterfacePrivateIpAddress();
primaryIp.setPrivateIpAddress(privateIp);
primaryIp.setPrimary(true);
ni.getPrivateIpAddresses().add(primaryIp);
return ni;
}
/**
* The interface an instance connect endpoint owns, built from the endpoint so the id
* DescribeInstanceConnectEndpoints publishes in networkInterfaceIdSet resolves in
* DescribeNetworkInterfaces for as long as the endpoint exists. Its address is the endpoint's
* own, already counted by privateIpsBySubnet from the endpoint record.
*/
private List<NetworkInterface> instanceConnectEndpointNetworkInterfacesOf(InstanceConnectEndpoint endpoint,
String ownerId) {
List<NetworkInterface> result = new ArrayList<>();
for (String eniId : endpoint.getNetworkInterfaceIds()) {
NetworkInterface ni = requesterManagedInterface(eniId, endpoint.getSubnetId(), endpoint.getVpcId(),
endpoint.getAvailabilityZone(),
"EC2 Instance Connect Endpoint " + endpoint.getInstanceConnectEndpointId(),
"ec2_instance_connect_endpoint", ownerId, endpoint.getPrivateIpAddress());
for (String securityGroupId : endpoint.getSecurityGroupIds()) {
GroupIdentifier group = new GroupIdentifier();
group.setGroupId(securityGroupId);
// Read for the account the endpoint was read for, as natNetworkInterfacesOf reads
// its subnet: the explicit-account overload may run under another ambient account.
String groupKey = key(endpoint.getRegion(), securityGroupId);
(securityGroups instanceof AccountAwareStorageBackend<SecurityGroup> aware
? aware.getForAccount(ownerId, groupKey).or(() -> aware.getLegacyForAccount(ownerId, groupKey))
: securityGroups.get(groupKey))
.ifPresent(sg -> group.setGroupName(sg.getGroupName()));
ni.getGroups().add(group);
}
result.add(ni);
}
return result;
}
// ─── EC2 Instance Connect Endpoints ─────────────────────────────────────
/** The public suffix every endpoint DNS name ends in; it resolves to 127.0.0.1 in public DNS. */
static final String INSTANCE_CONNECT_ENDPOINT_DNS_SUFFIX = "localhost.floci.io";
private static final Set<String> INSTANCE_CONNECT_ENDPOINT_IP_TYPES = Set.of("ipv4", "dualstack", "ipv6");
/**
* The names matchesInstanceConnectEndpointFilter implements, exactly the DescribeInstanceConnectEndpoints
* reference's list; tag:&lt;key&gt; is admitted through tag-key.
*/
private static final Set<String> INSTANCE_CONNECT_ENDPOINT_FILTERS = Set.of("instance-connect-endpoint-id",
"state", "vpc-id", "subnet-id", "tag-key", "tag-value");
/**
* Creates an endpoint in {@code subnetId}. Creation is immediate ({@code create-complete}); on
* AWS it takes a few minutes. The DNS names live under {@link #INSTANCE_CONNECT_ENDPOINT_DNS_SUFFIX},
* which resolves to the loopback address where Floci's HTTPS listener is published, and which
* Floci's wildcard server certificate covers. A replayed {@code clientToken} returns the endpoint
* the first call created; reused with another subnet, security group set, IP address type,
* PreserveClientIp or tag set it fails with {@code IdempotentParameterMismatch}.
*/
public InstanceConnectEndpoint createInstanceConnectEndpoint(String region, String subnetId,
List<String> securityGroupIds,
Boolean preserveClientIp, String ipAddressType,
List<Tag> tagList, String clientToken) {
return createInstanceConnectEndpoint(region, subnetId, securityGroupIds, preserveClientIp, ipAddressType,
tagList, clientToken, false);
}
/** As above; with {@code dryRun} the request is validated and then answered with DryRunOperation. */
public InstanceConnectEndpoint createInstanceConnectEndpoint(String region, String subnetId,
List<String> securityGroupIds,
Boolean preserveClientIp, String ipAddressType,
List<Tag> tagList, String clientToken,
boolean dryRun) {
// Held from the client-token replay scan to the save: two creates with one token then see
// each other, and deleteSubnet, which takes the same lock, cannot remove the subnet between
// requireSubnet and the save.
synchronized (attachmentTopologyLock(region)) {
return createInstanceConnectEndpointHeld(region, subnetId, securityGroupIds, preserveClientIp,
ipAddressType, tagList, clientToken, dryRun);
}
}
private InstanceConnectEndpoint createInstanceConnectEndpointHeld(String region, String subnetId,
List<String> securityGroupIds,
Boolean preserveClientIp, String ipAddressType,
List<Tag> tagList, String clientToken,
boolean dryRun) {
if (subnetId == null || subnetId.isBlank()) {
throw new AwsException("MissingParameter", "The request must contain the parameter SubnetId", 400);
}
Subnet subnet = requireSubnet(region, subnetId);
String type = ipAddressType == null || ipAddressType.isBlank() ? "ipv4" : ipAddressType;
if (!INSTANCE_CONNECT_ENDPOINT_IP_TYPES.contains(type)) {
throw new AwsException("InvalidParameterValue",
"Value (" + type + ") for parameter IpAddressType is invalid.", 400);
}
if (Boolean.TRUE.equals(preserveClientIp) && !"ipv4".equals(type)) {
throw new AwsException("InvalidParameterCombination",
"PreserveClientIp is only supported on IPv4 EC2 Instance Connect Endpoints.", 400);
}
List<String> groups = new ArrayList<>();
if (securityGroupIds == null || securityGroupIds.isEmpty()) {
securityGroups.scan(k -> true).stream()
.filter(sg -> region.equals(sg.getRegion()) && subnet.getVpcId().equals(sg.getVpcId())
&& "default".equals(sg.getGroupName()))
.findFirst()
.ifPresent(sg -> groups.add(sg.getGroupId()));
} else {
for (String groupId : securityGroupIds) {
SecurityGroup sg = getRequiredSecurityGroup(region, groupId);
if (!subnet.getVpcId().equals(sg.getVpcId())) {
throw new AwsException("InvalidParameter", "Security group " + groupId
+ " does not belong to VPC " + subnet.getVpcId() + ".", 400);
}
groups.add(groupId);
}
}
if (dryRun) {
throw new AwsException("DryRunOperation", "Request would have succeeded, but DryRun flag is set.", 412);
}
String token = clientToken != null && !clientToken.isBlank() ? clientToken : null;
if (token != null) {
// Compared after defaults are applied, so a retry that omits a defaulted parameter the
// first call also omitted still matches.
Optional<InstanceConnectEndpoint> replay = instanceConnectEndpoints.scan(k -> k.startsWith(region + "::"))
.stream().filter(existing -> token.equals(existing.getClientToken())).findFirst();
if (replay.isPresent()) {
InstanceConnectEndpoint first = replay.get();
if (!subnetId.equals(first.getSubnetId())
|| !new HashSet<>(groups).equals(new HashSet<>(first.getSecurityGroupIds()))
|| !type.equals(first.getIpAddressType())
|| Boolean.TRUE.equals(preserveClientIp) != first.isPreserveClientIp()
|| !tagMap(tagList).equals(tagMap(first.getCreationTags()))) {
throw new AwsException("IdempotentParameterMismatch",
"The client token '" + token + "' was already used with different parameters", 400);
}
return withTags(first);
}
}
String id = "eice-" + randomHex(17);
InstanceConnectEndpoint endpoint = new InstanceConnectEndpoint();
endpoint.setInstanceConnectEndpointId(id);
endpoint.setInstanceConnectEndpointArn(AwsArnUtils.Arn.of("ec2", region, callerAccountId(),
"instance-connect-endpoint/" + id).toString());
endpoint.setOwnerId(callerAccountId());
endpoint.setState("create-complete");
endpoint.setDnsName(id + "." + INSTANCE_CONNECT_ENDPOINT_DNS_SUFFIX);
endpoint.setFipsDnsName(id + "-fips." + INSTANCE_CONNECT_ENDPOINT_DNS_SUFFIX);
endpoint.setNetworkInterfaceIds(new ArrayList<>(List.of("eni-" + randomHex(17))));
endpoint.setVpcId(subnet.getVpcId());
endpoint.setSubnetId(subnetId);
endpoint.setAvailabilityZone(subnet.getAvailabilityZone());
endpoint.setAvailabilityZoneId(subnet.getAvailabilityZoneId());
endpoint.setCreatedAt(Instant.now());
endpoint.setPreserveClientIp(Boolean.TRUE.equals(preserveClientIp));
endpoint.setSecurityGroupIds(groups);
endpoint.setIpAddressType(type);
endpoint.setRegion(region);
endpoint.setClientToken(token);
endpoint.setCreationTags(InstanceConnectEndpoint.copyTags(tagList == null ? List.of() : tagList));
synchronized (privateIpAllocationLock) {
endpoint.setPrivateIpAddress(assignPrivateIp(region, subnetId));
instanceConnectEndpoints.put(key(region, id), endpoint);
}
if (tagList != null && !tagList.isEmpty()) {
createTags(region, List.of(id), tagList);
}
return withTags(endpoint);
}
public List<InstanceConnectEndpoint> describeInstanceConnectEndpoints(String region, List<String> ids,
Map<String, List<String>> filters) {
return describeInstanceConnectEndpoints(region, ids, filterList(filters));
}
public List<InstanceConnectEndpoint> describeInstanceConnectEndpoints(String region, List<String> ids,
List<Map.Entry<String, List<String>>> filters) {
// Checked before the scan, so a bad name fails even when no endpoint is there to test it on.
if (filters != null) {
requireSupportedFilters(filters.stream().map(Map.Entry::getKey).toList(),
INSTANCE_CONNECT_ENDPOINT_FILTERS);
}
for (String id : ids) {
requireInstanceConnectEndpoint(region, id);
}
return instanceConnectEndpoints.scan(k -> k.startsWith(region + "::")).stream()
.filter(endpoint -> ids.isEmpty() || ids.contains(endpoint.getInstanceConnectEndpointId()))
.map(this::withTags)
.filter(endpoint -> filters == null || filters.stream()
.allMatch(filter -> matchesInstanceConnectEndpointFilter(endpoint, filter.getKey(),
filter.getValue())))
.sorted(Comparator.comparing(InstanceConnectEndpoint::getInstanceConnectEndpointId))
.collect(Collectors.toList());
}
/**
* One page of {@link #describeInstanceConnectEndpoints}, in endpoint ID order. A null
* {@code maxResults} (omitted) returns every match; a value sent outside the model's 1 to 50
* (InstanceConnectEndpointMaxResults), zero and negatives included, is InvalidMaxResults, as
* DescribeTags refuses its own range.
*/
public PaginatedResult<InstanceConnectEndpoint> describeInstanceConnectEndpoints(
String region, List<String> ids, List<Map.Entry<String, List<String>>> filters,
Integer maxResults, String nextToken) {
if (maxResults != null && (maxResults < 1 || maxResults > 50)) {
throw new AwsException("InvalidMaxResults",
"Value (" + maxResults + ") for parameter MaxResults is invalid. "
+ "Expecting a value between 1 and 50.", 400);
}
return Pagination.paginate(describeInstanceConnectEndpoints(region, ids, filters),
InstanceConnectEndpoint::getInstanceConnectEndpointId,
maxResults == null ? Integer.MAX_VALUE : maxResults, nextToken, "eice",
token -> new AwsException("InvalidParameterValue", "Invalid NextToken", 400));
}
/** Deletes the endpoint and answers with it in {@code delete-in-progress}, as AWS does. */
public InstanceConnectEndpoint deleteInstanceConnectEndpoint(String region, String id) {
InstanceConnectEndpoint endpoint = withTags(requireInstanceConnectEndpoint(region, id));
synchronized (privateIpAllocationLock) {
instanceConnectEndpoints.delete(key(region, id));
if (vpcNetworkManager != null) {
vpcNetworkManager.releasePrivateIp(region, endpoint.getSubnetId(), endpoint.getPrivateIpAddress());
}
}
removeTags(region, id);
endpoint.getNetworkInterfaceIds().forEach(eniId -> removeTags(region, eniId));
endpoint.setState("delete-in-progress");
return endpoint;
}
private InstanceConnectEndpoint requireInstanceConnectEndpoint(String region, String id) {
return instanceConnectEndpoints.get(key(region, id)).orElseThrow(() -> new AwsException(
"InvalidInstanceConnectEndpointId.NotFound",
"The instance connect endpoint ID '" + id + "' does not exist", 400));
}
/** A copy of the stored endpoint carrying its current tags; the stored object is never changed. */
private InstanceConnectEndpoint withTags(InstanceConnectEndpoint stored) {
InstanceConnectEndpoint endpoint = new InstanceConnectEndpoint(stored);
endpoint.setTags(new ArrayList<>(resourceTags(stored.getRegion(), stored.getInstanceConnectEndpointId())));
return endpoint;
}
private boolean matchesInstanceConnectEndpointFilter(InstanceConnectEndpoint endpoint, String name,
List<String> values) {
if (name.startsWith("tag:") || "tag-key".equals(name)) {
return matchesTagFilter(endpoint.getTags(), name, values, Ec2Service::matchesFilterValue);
}
return switch (name) {
case "instance-connect-endpoint-id" -> matchesFilterValue(values, endpoint.getInstanceConnectEndpointId());
case "state" -> matchesFilterValue(values, endpoint.getState());
case "vpc-id" -> matchesFilterValue(values, endpoint.getVpcId());
case "subnet-id" -> matchesFilterValue(values, endpoint.getSubnetId());
case "tag-value" -> endpoint.getTags().stream().anyMatch(tag -> matchesFilterValue(values, tag.getValue()));
default -> throw new AwsException("InvalidParameterValue",
"The filter '" + name + "' is invalid", 400);
};
}
public List<NatGateway> describeNatGateways(String region, List<String> natGatewayIds,
Map<String, List<String>> filters) {
return describeNatGateways(region, natGatewayIds, filterList(filters));
@@ -14713,27 +15007,34 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
result.add(endpointNi);
}
// The ENI a NAT gateway owns. DescribeNatGateways publishes its id (aws_nat_gateway's
// network_interface_id), so it has to resolve here too. Unlike the endpoint arm above this
// one honours the explicit account: gateways and their subnets are read for safeAccount.
// The ENIs a NAT gateway and an instance connect endpoint own, NAT first. DescribeNatGateways
// publishes a gateway's id (aws_nat_gateway's network_interface_id) and an endpoint publishes
// its own in networkInterfaceIdSet, so both have to resolve here too. Unlike the VPC endpoint
// arm above this one honours the explicit account: gateways, endpoints and the records their
// interfaces are built from are read for safeAccount.
List<NetworkInterface> managedInterfaces = new ArrayList<>();
for (NatGateway natGateway : natGatewaysOf(safeAccount)) {
if (!region.equals(natGateway.getRegion())) {
if (region.equals(natGateway.getRegion())) {
managedInterfaces.addAll(natNetworkInterfacesOf(natGateway, safeAccount));
}
}
List<InstanceConnectEndpoint> regionEndpoints =
instanceConnectEndpoints instanceof AccountAwareStorageBackend<InstanceConnectEndpoint> aware
? aware.scanForAccount(safeAccount, k -> k.startsWith(region + "::"))
: instanceConnectEndpoints.scan(k -> k.startsWith(region + "::"));
for (InstanceConnectEndpoint endpoint : regionEndpoints) {
managedInterfaces.addAll(instanceConnectEndpointNetworkInterfacesOf(endpoint, safeAccount));
}
for (NetworkInterface managedNi : managedInterfaces) {
String managedEniId = managedNi.getNetworkInterfaceId();
if (foundIds.contains(managedEniId)
|| !networkInterfaceIds.isEmpty() && !networkInterfaceIds.contains(managedEniId)) {
continue;
}
for (NetworkInterface natNi : natNetworkInterfacesOf(natGateway, safeAccount)) {
String natEniId = natNi.getNetworkInterfaceId();
if (foundIds.contains(natEniId)) {
continue;
}
if (!networkInterfaceIds.isEmpty() && !networkInterfaceIds.contains(natEniId)) {
continue;
}
foundIds.add(natEniId);
natNi.getTagSet().addAll(tagsOf(safeAccount, region, natEniId).orElse(List.of()));
if (!matchesFilters(natNi, filters, region)) {
continue;
}
result.add(natNi);
foundIds.add(managedEniId);
managedNi.getTagSet().addAll(tagsOf(safeAccount, region, managedEniId).orElse(List.of()));
if (matchesFilters(managedNi, filters, region)) {
result.add(managedNi);
}
}
@@ -0,0 +1,132 @@
package io.github.hectorvent.floci.services.ec2.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
/** An EC2 Instance Connect Endpoint: the tunnel entry point into one subnet's VPC. */
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)
public class InstanceConnectEndpoint {
private String instanceConnectEndpointId;
private String instanceConnectEndpointArn;
private String ownerId;
private String state;
private String dnsName;
private String fipsDnsName;
private List<String> networkInterfaceIds = new ArrayList<>();
private String vpcId;
private String subnetId;
private String availabilityZone;
private String availabilityZoneId;
private Instant createdAt;
private boolean preserveClientIp;
private List<String> securityGroupIds = new ArrayList<>();
private String ipAddressType;
private String region;
/** The endpoint's interface address in its subnet: the source instances see when the client IP is not preserved. */
private String privateIpAddress;
private String clientToken;
/** The tags the create request carried, compared on a ClientToken replay; later CreateTags calls do not change them. */
private List<Tag> creationTags = new ArrayList<>();
private List<Tag> tags = new ArrayList<>();
public InstanceConnectEndpoint() {}
/** A copy whose lists are its own, so a caller can change it without touching the stored endpoint. */
public InstanceConnectEndpoint(InstanceConnectEndpoint other) {
instanceConnectEndpointId = other.instanceConnectEndpointId;
instanceConnectEndpointArn = other.instanceConnectEndpointArn;
ownerId = other.ownerId;
state = other.state;
dnsName = other.dnsName;
fipsDnsName = other.fipsDnsName;
networkInterfaceIds = new ArrayList<>(other.networkInterfaceIds);
vpcId = other.vpcId;
subnetId = other.subnetId;
availabilityZone = other.availabilityZone;
availabilityZoneId = other.availabilityZoneId;
createdAt = other.createdAt;
preserveClientIp = other.preserveClientIp;
securityGroupIds = new ArrayList<>(other.securityGroupIds);
ipAddressType = other.ipAddressType;
region = other.region;
privateIpAddress = other.privateIpAddress;
clientToken = other.clientToken;
creationTags = copyTags(other.creationTags);
tags = copyTags(other.tags);
}
/** A list of new Tag objects equal to {@code source}'s, so neither side can change the other's. */
public static List<Tag> copyTags(List<Tag> source) {
List<Tag> copy = new ArrayList<>(source.size());
for (Tag tag : source) {
copy.add(new Tag(tag.getKey(), tag.getValue()));
}
return copy;
}
public String getInstanceConnectEndpointId() { return instanceConnectEndpointId; }
public void setInstanceConnectEndpointId(String id) { this.instanceConnectEndpointId = id; }
public String getInstanceConnectEndpointArn() { return instanceConnectEndpointArn; }
public void setInstanceConnectEndpointArn(String arn) { this.instanceConnectEndpointArn = arn; }
public String getOwnerId() { return ownerId; }
public void setOwnerId(String ownerId) { this.ownerId = ownerId; }
public String getState() { return state; }
public void setState(String state) { this.state = state; }
public String getDnsName() { return dnsName; }
public void setDnsName(String dnsName) { this.dnsName = dnsName; }
public String getFipsDnsName() { return fipsDnsName; }
public void setFipsDnsName(String fipsDnsName) { this.fipsDnsName = fipsDnsName; }
public List<String> getNetworkInterfaceIds() { return networkInterfaceIds; }
public void setNetworkInterfaceIds(List<String> ids) { this.networkInterfaceIds = ids != null ? ids : new ArrayList<>(); }
public String getVpcId() { return vpcId; }
public void setVpcId(String vpcId) { this.vpcId = vpcId; }
public String getSubnetId() { return subnetId; }
public void setSubnetId(String subnetId) { this.subnetId = subnetId; }
public String getAvailabilityZone() { return availabilityZone; }
public void setAvailabilityZone(String availabilityZone) { this.availabilityZone = availabilityZone; }
public String getAvailabilityZoneId() { return availabilityZoneId; }
public void setAvailabilityZoneId(String availabilityZoneId) { this.availabilityZoneId = availabilityZoneId; }
public Instant getCreatedAt() { return createdAt; }
public void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; }
public boolean isPreserveClientIp() { return preserveClientIp; }
public void setPreserveClientIp(boolean preserveClientIp) { this.preserveClientIp = preserveClientIp; }
public List<String> getSecurityGroupIds() { return securityGroupIds; }
public void setSecurityGroupIds(List<String> ids) { this.securityGroupIds = ids != null ? ids : new ArrayList<>(); }
public String getIpAddressType() { return ipAddressType; }
public void setIpAddressType(String ipAddressType) { this.ipAddressType = ipAddressType; }
public String getRegion() { return region; }
public void setRegion(String region) { this.region = region; }
public String getPrivateIpAddress() { return privateIpAddress; }
public void setPrivateIpAddress(String privateIpAddress) { this.privateIpAddress = privateIpAddress; }
public String getClientToken() { return clientToken; }
public void setClientToken(String clientToken) { this.clientToken = clientToken; }
public List<Tag> getCreationTags() { return creationTags; }
public void setCreationTags(List<Tag> creationTags) { this.creationTags = creationTags != null ? creationTags : new ArrayList<>(); }
public List<Tag> getTags() { return tags; }
public void setTags(List<Tag> tags) { this.tags = tags != null ? tags : new ArrayList<>(); }
}