mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(ec2): honour DryRun on the transit gateway, Client VPN, key pair, launch template and describe calls (#9075)
This commit is contained in:
1 parent
8a4880f7b3
commit
ad8498a813
9 files changed
+676
-81
No files matched your search
+41
-41
@@ -443,7 +443,7 @@ naming different VPCs find nothing.
|
||||
| DescribeDhcpOptions | Lists DHCP options sets by ID or filters, with paginated results. |
|
||||
| AssociateDhcpOptions | Associates an options set with a VPC; `default` leaves the VPC with no DHCP options. |
|
||||
| DeleteDhcpOptions | Deletes an unassociated DHCP options set. |
|
||||
| DescribeVpcEndpointServices | Lists common AWS interface endpoint services, and S3 and DynamoDB (gateway and interface), in every availability zone, named per partition (see [Partitions](../configuration/partitions.md)). A `ServiceName` filter is echoed back as asked. |
|
||||
| DescribeVpcEndpointServices | Lists common AWS interface endpoint services, and S3 and DynamoDB (gateway and interface), in every availability zone, named per partition (see [Partitions](../configuration/partitions.md)). A `ServiceName` filter is echoed back as asked. `DryRun=true` is answered with `DryRunOperation` before any id is looked up, so a well-formed id that names nothing still gets it. |
|
||||
| CreateVpcEndpoint | Creates a VPC endpoint record, including its `PolicyDocument` and the per-subnet IPv4 and IPv6 addresses named by `SubnetConfiguration.N`. `IpAddressType` defaults to `ipv4`. Interface and gateway address types are stored as metadata. Synthesized endpoint interfaces still carry IPv4 only; IPv6 networking is not emulated. An `Ipv4` value outside the named subnet's CIDR, or among the first four or the last address AWS reserves in it, is rejected with `InvalidParameterValue`. |
|
||||
| DescribeVpcEndpoints | Lists or returns stored VPC endpoints, including their IP address type. |
|
||||
| ModifyVpcEndpoint | Associates or disassociates route tables, subnets and security groups, sets or resets the endpoint policy, and updates stored `IpAddressType` metadata. Omitting the type preserves its current value; malformed types are rejected before changes are applied. `SubnetConfiguration.N` replaces the addresses pinned for a subnet, under the same address validation as CreateVpcEndpoint. `DnsOptions` is accepted and ignored. |
|
||||
@@ -523,7 +523,7 @@ and `sk-ecdsa-sha2-nistp256@openssh.com`.
|
||||
|--------|-------------|
|
||||
| CreateKeyPair | Creates an RSA or ED25519 key pair and returns its private key as PEM or as a PuTTY `.ppk` file, with `key-pair` tags from `TagSpecification` returned in `tagSet`. |
|
||||
| DescribeKeyPairs | Lists or returns stored key pairs. |
|
||||
| DeleteKeyPair | Deletes a key pair from the local EC2 store. |
|
||||
| DeleteKeyPair | Deletes a key pair from the local EC2 store. `DryRun=true` is answered with `DryRunOperation` and deletes nothing. |
|
||||
| ImportKeyPair | Imports a public key as a local key pair, with `key-pair` tags from `TagSpecification` returned in `tagSet`. |
|
||||
|
||||
`CreateKeyPair` creates a 2048-bit RSA key unless `KeyType=ed25519` asks for an ED25519 key, and
|
||||
@@ -628,7 +628,7 @@ Nested launch-template tags follow AWS's case-sensitive check: `aws:` is rejecte
|
||||
| Action | Description |
|
||||
|--------|-------------|
|
||||
| CreateRouteTable | Creates a route table in a VPC. |
|
||||
| DescribeRouteTables | Lists or returns stored route tables. |
|
||||
| DescribeRouteTables | Lists or returns stored route tables. `DryRun=true` is answered with `DryRunOperation` before any id is looked up, so a well-formed id that names nothing still gets it. |
|
||||
| DeleteRouteTable | Deletes a route table from the local EC2 store. |
|
||||
| AssociateRouteTable | Associates a route table with a subnet. |
|
||||
| DisassociateRouteTable | Removes a route table association. |
|
||||
@@ -675,7 +675,7 @@ matching how AWS itself responds.
|
||||
| Action | Description |
|
||||
|--------|-------------|
|
||||
| CreateNetworkAcl | Creates a network ACL in a VPC, with `network-acl` tags from `TagSpecification`. |
|
||||
| DescribeNetworkAcls | Lists or returns stored network ACLs. |
|
||||
| DescribeNetworkAcls | Lists or returns stored network ACLs. `DryRun=true` is answered with `DryRunOperation` before any id is looked up, so a well-formed id that names nothing still gets it. |
|
||||
| DeleteNetworkAcl | Deletes a network ACL from the local EC2 store. |
|
||||
| CreateNetworkAclEntry | Adds an entry to a network ACL. The entry keeps whichever of `CidrBlock` or `Ipv6CidrBlock` was supplied, and `DescribeNetworkAcls` returns it under the same name. `IcmpTypeCode` is kept for ICMP (`1`) and ICMPv6 (`58`) entries only. |
|
||||
| ReplaceNetworkAclEntry | Replaces an entry in a network ACL, including its `CidrBlock` or `Ipv6CidrBlock` and, for ICMP and ICMPv6 entries, its `IcmpTypeCode`. |
|
||||
@@ -686,9 +686,9 @@ matching how AWS itself responds.
|
||||
|
||||
| Action | Description |
|
||||
|--------|-------------|
|
||||
| DescribePrefixLists | Returns prefix lists known to the local EC2 service. |
|
||||
| DescribePrefixLists | Returns prefix lists known to the local EC2 service. `DryRun=true` is answered with `DryRunOperation` before any id is looked up, so a well-formed id that names nothing still gets it. |
|
||||
| CreateManagedPrefixList | Creates a customer-managed prefix list with its initial entries. |
|
||||
| DescribeManagedPrefixLists | Lists customer-managed and AWS-managed prefix lists. |
|
||||
| DescribeManagedPrefixLists | Lists customer-managed and AWS-managed prefix lists. `DryRun=true` is answered with `DryRunOperation` before any id is looked up, so a well-formed id that names nothing still gets it. |
|
||||
| GetManagedPrefixListEntries | Returns the entries of a prefix list, optionally at an earlier version. |
|
||||
| ModifyManagedPrefixList | Adds or removes entries, renames the list, or raises its entry limit. |
|
||||
| DeleteManagedPrefixList | Deletes a customer-managed prefix list. |
|
||||
@@ -754,9 +754,9 @@ exist returns `InvalidPrefixListID.NotFound`, so a typo cannot leave a rule poin
|
||||
| Action | Description |
|
||||
|--------|-------------|
|
||||
| CreateTransitGateway | Creates a transit gateway, applying AWS's option defaults and minting its default route table. |
|
||||
| DescribeTransitGateways | Lists or returns stored transit gateways. |
|
||||
| DescribeTransitGateways | Lists or returns stored transit gateways. `DryRun=true` is answered with `DryRunOperation` before any id is looked up, so a well-formed id that names nothing still gets it. |
|
||||
| ModifyTransitGateway | Updates a transit gateway's description, options and CIDR blocks. |
|
||||
| DeleteTransitGateway | Deletes a transit gateway and the default route table created with it. |
|
||||
| DeleteTransitGateway | Deletes a transit gateway and the default route table created with it. `DryRun=true` is answered with `DryRunOperation` and deletes nothing. |
|
||||
|
||||
Transit gateway metadata only: nothing routes packets, and the value is in ids that later
|
||||
resources can reference and describes that round-trip so plans converge.
|
||||
@@ -784,9 +784,9 @@ and `DescribeTransitGateways` include it.
|
||||
| Action | Description |
|
||||
|--------|-------------|
|
||||
| CreateTransitGatewayVpcAttachment | Attaches a VPC to a transit gateway through one subnet per availability zone. |
|
||||
| DescribeTransitGatewayVpcAttachments | Lists or returns VPC attachments with their subnets and options. |
|
||||
| DescribeTransitGatewayAttachments | Returns the same attachments in the resource-agnostic shape, including the route table association. |
|
||||
| DescribeTransitGatewayConnects | Always returns an empty list, since Connect attachments cannot be created yet; requested ids are still validated. |
|
||||
| DescribeTransitGatewayVpcAttachments | Lists or returns VPC attachments with their subnets and options. `DryRun=true` is answered with `DryRunOperation` before any id is looked up, so a well-formed id that names nothing still gets it. |
|
||||
| DescribeTransitGatewayAttachments | Returns the same attachments in the resource-agnostic shape, including the route table association. `DryRun=true` is answered with `DryRunOperation` before any id is looked up, so a well-formed id that names nothing still gets it. |
|
||||
| DescribeTransitGatewayConnects | Always returns an empty list, since Connect attachments cannot be created yet; requested ids are still validated. `DryRun=true` is answered with `DryRunOperation` before that validation. |
|
||||
| ModifyTransitGatewayVpcAttachment | Adds or removes attachment subnets and updates its options. |
|
||||
| DeleteTransitGatewayVpcAttachment | Deletes a VPC attachment. |
|
||||
|
||||
@@ -817,8 +817,8 @@ real AWS rejects; Floci does not model subnet IPv6 allocation.
|
||||
| Action | Description |
|
||||
|--------|-------------|
|
||||
| CreateTransitGatewayPeeringAttachment | Requests a peering between a local transit gateway and a peer one, pending acceptance. |
|
||||
| DescribeTransitGatewayPeeringAttachments | Lists or returns peering attachments, from either side's region. |
|
||||
| AcceptTransitGatewayPeeringAttachment | Accepts a pending peering attachment from the accepter's region. |
|
||||
| DescribeTransitGatewayPeeringAttachments | Lists or returns peering attachments, from either side's region. `DryRun=true` is answered with `DryRunOperation` before any id is looked up, so a well-formed id that names nothing still gets it. |
|
||||
| AcceptTransitGatewayPeeringAttachment | Accepts a pending peering attachment from the accepter's region. `DryRun=true` is answered with `DryRunOperation` before the attachment is looked up, and accepts nothing. |
|
||||
| DeleteTransitGatewayPeeringAttachment | Deletes a peering attachment from either side. |
|
||||
|
||||
The requester's gateway must exist; the peer gateway is recorded as given and not resolved, since
|
||||
@@ -838,19 +838,19 @@ that rejects the peering instead. Peering attachments do not yet appear in
|
||||
| Action | Description |
|
||||
|--------|-------------|
|
||||
| CreateTransitGatewayRouteTable | Creates a route table on a transit gateway. |
|
||||
| DescribeTransitGatewayRouteTables | Lists or returns stored transit gateway route tables. |
|
||||
| DescribeTransitGatewayRouteTables | Lists or returns stored transit gateway route tables. `DryRun=true` is answered with `DryRunOperation` before any id is looked up, so a well-formed id that names nothing still gets it. |
|
||||
| DeleteTransitGatewayRouteTable | Deletes a route table, along with its propagations and static routes. |
|
||||
| AssociateTransitGatewayRouteTable | Associates an attachment with a route table. |
|
||||
| AssociateTransitGatewayRouteTable | Associates an attachment with a route table. `DryRun=true` is answered with `DryRunOperation` and associates nothing. |
|
||||
| DisassociateTransitGatewayRouteTable | Removes an attachment's association. |
|
||||
| GetTransitGatewayRouteTableAssociations | Lists the attachments associated with a route table. |
|
||||
| EnableTransitGatewayRouteTablePropagation | Propagates an attachment's routes into a route table. |
|
||||
| DisableTransitGatewayRouteTablePropagation | Stops an attachment propagating into a route table. |
|
||||
| DisableTransitGatewayRouteTablePropagation | Stops an attachment propagating into a route table. `DryRun=true` is answered with `DryRunOperation` and leaves the propagation enabled. |
|
||||
| GetTransitGatewayRouteTablePropagations | Lists the propagations into a route table. |
|
||||
| CreateTransitGatewayRoute | Adds a static or blackhole route to a route table. |
|
||||
| CreateTransitGatewayRoute | Adds a static or blackhole route to a route table. `DryRun=true` is answered with `DryRunOperation` and writes no route. |
|
||||
| DeleteTransitGatewayRoute | Removes a static route. |
|
||||
| ReplaceTransitGatewayRoute | Points an existing route at a different target, or writes it if absent. |
|
||||
| SearchTransitGatewayRoutes | Returns a route table's routes, static and propagated, filtered. |
|
||||
| ExportTransitGatewayRoutes | Reports the S3 object a route-table export would be written to. |
|
||||
| ExportTransitGatewayRoutes | Reports the S3 object a route-table export would be written to. `DryRun=true` is answered with `DryRunOperation`. |
|
||||
|
||||
A route table asked for by name is never a default one; only the table a gateway mints for itself
|
||||
carries `defaultAssociationRouteTable` or `defaultPropagationRouteTable`. Deleting a route table is
|
||||
@@ -891,7 +891,7 @@ Route table ids follow the live API's own inconsistency: an id that does not exi
|
||||
| Action | Description |
|
||||
|--------|-------------|
|
||||
| CreateNatGateway | Creates a NAT gateway record. |
|
||||
| DescribeNatGateways | Lists or returns stored NAT gateways. |
|
||||
| DescribeNatGateways | Lists or returns stored NAT gateways. `DryRun=true` is answered with `DryRunOperation` before any id is looked up, so a well-formed id that names nothing still gets it. |
|
||||
| DeleteNatGateway | Deletes a NAT gateway record. |
|
||||
|
||||
Every NAT gateway Floci creates is zonal: it sits in the subnet it was created in, and responses
|
||||
@@ -937,8 +937,8 @@ A repeated `ClientToken` returns the endpoint the first call created (`Idempoten
|
||||
| Action | Description |
|
||||
|--------|-------------|
|
||||
| CreateCapacityReservation | Reserves EC2 instance capacity in a specific Availability Zone. |
|
||||
| DescribeCapacityReservations | Lists or returns stored Capacity Reservations. |
|
||||
| ModifyCapacityReservation | Updates `InstanceCount`, `EndDate`, `EndDateType` or `InstanceMatchCriteria` in place. |
|
||||
| DescribeCapacityReservations | Lists or returns stored Capacity Reservations. `DryRun=true` is answered with `DryRunOperation` before any id is looked up, so a well-formed id that names nothing still gets it. |
|
||||
| ModifyCapacityReservation | Updates `InstanceCount`, `EndDate`, `EndDateType` or `InstanceMatchCriteria` in place. `DryRun=true` is answered with `DryRunOperation` and changes nothing. |
|
||||
| CancelCapacityReservation | Marks a Capacity Reservation `cancelled` and its available count `0`, matching real AWS's retain-but-cancel behaviour rather than deleting the record. |
|
||||
|
||||
`InstanceType`, `InstancePlatform` and `InstanceCount` are required, matching the AWS API, and
|
||||
@@ -1027,7 +1027,7 @@ fixed socket/core/vCPU shape rather than one derived from the instance family.
|
||||
| DescribeAddresses | Lists or returns stored Elastic IP address records. |
|
||||
| DescribeAddressesAttribute | Returns allocation ID and public IP attributes for Elastic IP addresses. |
|
||||
| AssociateAddress | Associates an Elastic IP address with a resource. |
|
||||
| DisassociateAddress | Removes an Elastic IP address association. |
|
||||
| DisassociateAddress | Removes an Elastic IP address association. `DryRun=true` is answered with `DryRunOperation` and leaves the address associated. |
|
||||
| ReleaseAddress | Releases an Elastic IP address record. |
|
||||
|
||||
`AllocateAddress` and `DescribeAddresses` return `PublicIpv4Pool` and `NetworkBorderGroup`.
|
||||
@@ -1084,8 +1084,8 @@ allocated address.
|
||||
| Action | Description |
|
||||
|--------|-------------|
|
||||
| DescribeAvailabilityZones | Returns the configured local availability zones. |
|
||||
| DescribeRegions | Returns the regions known to the local EC2 service. |
|
||||
| DescribeAccountAttributes | Returns local account-level EC2 attributes. |
|
||||
| DescribeRegions | Returns the regions known to the local EC2 service. `DryRun=true` is answered with `DryRunOperation`. |
|
||||
| DescribeAccountAttributes | Returns local account-level EC2 attributes. `DryRun=true` is answered with `DryRunOperation`. |
|
||||
|
||||
The modeled zones are standard Availability Zones. Each reports `NetworkBorderGroup` as its
|
||||
Region, such as `eu-west-1`. Local Zones and Wavelength Zones are not modeled.
|
||||
@@ -1101,7 +1101,7 @@ regions, for which AWS publishes no zone id, keep the whole region as the prefix
|
||||
|
||||
| Action | Description |
|
||||
|--------|-------------|
|
||||
| DescribeInstanceTypes | Returns instance type metadata known to the local EC2 service, including `burstablePerformanceSupported` for the T families. |
|
||||
| DescribeInstanceTypes | Returns instance type metadata known to the local EC2 service, including `burstablePerformanceSupported` for the T families. `DryRun=true` is answered with `DryRunOperation` before any id is looked up, so a well-formed id that names nothing still gets it. |
|
||||
| DescribeInstanceTypeOfferings | Returns instance type offerings for the requested location filters. An `instance-type` filter value may hold `*` and `?` wildcards, such as `t3.*`. |
|
||||
|
||||
### Launch Templates
|
||||
@@ -1113,7 +1113,7 @@ regions, for which AWS publishes no zone id, keep the whole region as the prefix
|
||||
| DescribeLaunchTemplates | Lists or returns stored launch templates. |
|
||||
| DescribeLaunchTemplateVersions | Lists versions stored for a launch template. |
|
||||
| ModifyLaunchTemplate | Updates launch template metadata such as the default version. |
|
||||
| DeleteLaunchTemplate | Deletes a launch template and its versions. |
|
||||
| DeleteLaunchTemplate | Deletes a launch template and its versions. `DryRun=true` is answered with `DryRunOperation` and deletes nothing. |
|
||||
| DeleteLaunchTemplateVersions | Deletes up to 200 numbered versions by template ID or name, with separate success and error items. The default version is retained, and `DryRun` leaves all versions unchanged. |
|
||||
|
||||
Launch templates store versioned launch data. New template versions can be created from an existing source version, and `ModifyLaunchTemplate` updates the default version used by later launches.
|
||||
@@ -1312,7 +1312,7 @@ profile.
|
||||
| Action | Description |
|
||||
|--------|-------------|
|
||||
| CreateNetworkInterface | Creates a standalone elastic network interface (ENI) in a subnet, unattached. `Ipv6Addresses` names IPv6 addresses inside one of the subnet's IPv6 blocks; `Ipv6AddressCount` draws that many from the subnet. Left out, the subnet's `AssignIpv6AddressOnCreation` gives the interface one address; an explicit `0` overrides it. Create and describe responses also expose the first assigned IPv6 address as `ipv6Address`, omitting it when the interface has none. |
|
||||
| DescribeNetworkInterfaces | Lists network interfaces known to the local EC2 service: an instance's implicit primary interface, an EKS cluster node's primary interface, and standalone ENIs created via `CreateNetworkInterface`. |
|
||||
| DescribeNetworkInterfaces | Lists network interfaces known to the local EC2 service: an instance's implicit primary interface, an EKS cluster node's primary interface, and standalone ENIs created via `CreateNetworkInterface`. `DryRun=true` is answered with `DryRunOperation` before any id is looked up, so a well-formed id that names nothing still gets it. |
|
||||
| AttachNetworkInterface | Attaches an available standalone ENI to a running or stopped instance at a device index. |
|
||||
| DetachNetworkInterface | Detaches a standalone ENI by attachment ID, returning it to `available`. |
|
||||
| AssignIpv6Addresses | Gives a standalone ENI or an instance's launch-created interface the named IPv6 addresses (`Ipv6Addresses.N`) or a count drawn from its subnet (`Ipv6AddressCount`); one of the two is required. `assignedIpv6Addresses` lists only the addresses the call added. An address outside the subnet's IPv6 blocks answers `InvalidParameterValue`, one another interface holds `InvalidIPAddress.InUse`. Prefix delegation (`Ipv6Prefix`, `Ipv6PrefixCount`) answers `UnsupportedOperation`. |
|
||||
@@ -1408,7 +1408,7 @@ Validation matches AWS behavior:
|
||||
|--------|-------------|
|
||||
| CreateFlowLogs | Creates flow logs for the given resources; returns one flow log id per resource. A `vpc-flow-log` `TagSpecification` tags each one, and `DescribeFlowLogs` returns the tags. |
|
||||
| DescribeFlowLogs | Lists stored flow logs, optionally filtered by id. |
|
||||
| DeleteFlowLogs | Deletes the named flow logs. |
|
||||
| DeleteFlowLogs | Deletes the named flow logs. `DryRun=true` is answered with `DryRunOperation` and deletes nothing. |
|
||||
|
||||
### Spot Instances
|
||||
|
||||
@@ -1439,20 +1439,20 @@ Spot prices returned by `DescribeSpotPriceHistory` are synthetic and derived det
|
||||
| Action | Description |
|
||||
|--------|-------------|
|
||||
| CreateClientVpnEndpoint | Creates an endpoint; a `client-vpn-endpoint` `TagSpecification` tags it. |
|
||||
| DescribeClientVpnEndpoints | Lists endpoints, or the ones `ClientVpnEndpointId.N` names. |
|
||||
| ModifyClientVpnEndpoint | Changes the members the request gives. |
|
||||
| DeleteClientVpnEndpoint | Deletes an endpoint with no associated target networks. |
|
||||
| DescribeClientVpnEndpoints | Lists endpoints, or the ones `ClientVpnEndpointId.N` names. `DryRun=true` is answered with `DryRunOperation`. |
|
||||
| ModifyClientVpnEndpoint | Changes the members the request gives. `DryRun=true` is answered with `DryRunOperation` and changes nothing. |
|
||||
| DeleteClientVpnEndpoint | Deletes an endpoint with no associated target networks. `DryRun=true` is answered with `DryRunOperation` and deletes nothing. |
|
||||
| AssociateClientVpnTargetNetwork | Associates a subnet and adds the route to its VPC through it. |
|
||||
| DescribeClientVpnTargetNetworks | Lists an endpoint's associations. |
|
||||
| DisassociateClientVpnTargetNetwork | Removes an association and the routes through its subnet. |
|
||||
| ApplySecurityGroupsToClientVpnTargetNetwork | Sets the security groups the endpoint applies in its VPC. |
|
||||
| AuthorizeClientVpnIngress | Adds an authorization rule for a network, for one group or all. |
|
||||
| DescribeClientVpnAuthorizationRules | Lists an endpoint's authorization rules. |
|
||||
| DescribeClientVpnTargetNetworks | Lists an endpoint's associations. `DryRun=true` is answered with `DryRunOperation`. |
|
||||
| DisassociateClientVpnTargetNetwork | Removes an association and the routes through its subnet. `DryRun=true` checks the endpoint and the association first, so an unknown one is refused as for the real call, and is otherwise answered with `DryRunOperation` and disassociates nothing. |
|
||||
| ApplySecurityGroupsToClientVpnTargetNetwork | Sets the security groups the endpoint applies in its VPC. `DryRun=true` is answered with `DryRunOperation` before the endpoint is looked up, and applies nothing. |
|
||||
| AuthorizeClientVpnIngress | Adds an authorization rule for a network, for one group or all. `DryRun=true` is answered with `DryRunOperation` and adds no rule. |
|
||||
| DescribeClientVpnAuthorizationRules | Lists an endpoint's authorization rules. `DryRun=true` is answered with `DryRunOperation`. |
|
||||
| RevokeClientVpnIngress | Removes an authorization rule. |
|
||||
| CreateClientVpnRoute | Adds a route through an associated subnet. |
|
||||
| DescribeClientVpnRoutes | Lists an endpoint's routes, the ones associations added included. |
|
||||
| DeleteClientVpnRoute | Removes a route the endpoint was given. |
|
||||
| ExportClientVpnClientConfiguration | Returns the OpenVPN client configuration for the endpoint. |
|
||||
| DescribeClientVpnRoutes | Lists an endpoint's routes, the ones associations added included. `DryRun=true` is answered with `DryRunOperation`. |
|
||||
| DeleteClientVpnRoute | Removes a route the endpoint was given. `DryRun=true` is answered with `DryRunOperation` and deletes nothing. |
|
||||
| ExportClientVpnClientConfiguration | Returns the OpenVPN client configuration for the endpoint. `DryRun=true` looks the endpoint up first, so an unknown one is refused as for the real call, and is otherwise answered with `DryRunOperation`. |
|
||||
|
||||
Client VPN is a configuration registry: no VPN server runs, so clients cannot connect. An endpoint
|
||||
is `pending-associate` until a subnet is associated, then `available`, and its DNS name is
|
||||
@@ -1494,9 +1494,9 @@ groups, the VPC's default security group.
|
||||
|--------|-------------|
|
||||
| EnableEbsEncryptionByDefault | Turns on default encryption for new volumes in the region. |
|
||||
| DisableEbsEncryptionByDefault | Turns default encryption back off. |
|
||||
| GetEbsEncryptionByDefault | Reports whether default encryption is on. |
|
||||
| GetEbsEncryptionByDefault | Reports whether default encryption is on. `DryRun=true` is answered with `DryRunOperation`. |
|
||||
| ModifyEbsDefaultKmsKeyId | Sets the KMS key an encrypted volume gets when it names none. |
|
||||
| GetEbsDefaultKmsKeyId | Reports the current default KMS key. |
|
||||
| GetEbsDefaultKmsKeyId | Reports the current default KMS key. `DryRun=true` is answered with `DryRunOperation`. |
|
||||
| ResetEbsDefaultKmsKeyId | Restores the AWS-managed default key. |
|
||||
|
||||
These are account-level settings scoped per region, not per volume, and nothing here encrypts anything — no volume's stored bytes change. LZA's SecurityStack drives them through its `Custom::EnableEbsEncryptionByDefault` Lambda, which calls enable plus `ModifyEbsDefaultKmsKeyId` on create and disable on delete, then reads the state back with the two `Get` calls.
|
||||
|
||||
@@ -74,6 +74,7 @@ class Ec2ClientVpnHandler {
|
||||
}
|
||||
|
||||
Response describe(MultivaluedMap<String, String> p, String region) {
|
||||
Ec2QueryHandler.checkDryRun(p);
|
||||
List<Map.Entry<String, List<String>>> filters = filters(p, ENDPOINT_FILTERS);
|
||||
List<ClientVpnEndpoint> endpoints = clientVpn.describeEndpoints(region, getList(p, "ClientVpnEndpointId"));
|
||||
XmlBuilder xml = startResponse("DescribeClientVpnEndpoints").start("clientVpnEndpoint");
|
||||
@@ -104,12 +105,12 @@ class Ec2ClientVpnHandler {
|
||||
p.getFirst("ClientConnectOptions.LambdaFunctionArn"), intParam(p, "SessionTimeoutHours"),
|
||||
boolParam(p, "ClientLoginBannerOptions.Enabled"), p.getFirst("ClientLoginBannerOptions.BannerText"),
|
||||
boolParam(p, "ClientRouteEnforcementOptions.Enforced"), boolParam(p, "DisconnectOnSessionTimeout"));
|
||||
clientVpn.modifyEndpoint(region, p.getFirst("ClientVpnEndpointId"), change);
|
||||
clientVpn.modifyEndpoint(region, p.getFirst("ClientVpnEndpointId"), change, Ec2QueryHandler.dryRun(p));
|
||||
return booleanResponse("ModifyClientVpnEndpoint");
|
||||
}
|
||||
|
||||
Response delete(MultivaluedMap<String, String> p, String region) {
|
||||
clientVpn.deleteEndpoint(region, p.getFirst("ClientVpnEndpointId"));
|
||||
clientVpn.deleteEndpoint(region, p.getFirst("ClientVpnEndpointId"), Ec2QueryHandler.dryRun(p));
|
||||
return endResponse(status(startResponse("DeleteClientVpnEndpoint"), "deleting"), "DeleteClientVpnEndpoint");
|
||||
}
|
||||
|
||||
@@ -122,6 +123,7 @@ class Ec2ClientVpnHandler {
|
||||
}
|
||||
|
||||
Response describeTargetNetworks(MultivaluedMap<String, String> p, String region) {
|
||||
answerDryRunBeforeLookup(p);
|
||||
String id = p.getFirst("ClientVpnEndpointId");
|
||||
List<Map.Entry<String, List<String>>> filters = filters(p, TARGET_NETWORK_FILTERS);
|
||||
List<TargetNetwork> networks = clientVpn.describeTargetNetworks(region, id, getList(p, "AssociationIds"));
|
||||
@@ -152,13 +154,14 @@ class Ec2ClientVpnHandler {
|
||||
|
||||
Response disassociate(MultivaluedMap<String, String> p, String region) {
|
||||
TargetNetwork network = clientVpn.disassociate(region, p.getFirst("ClientVpnEndpointId"),
|
||||
p.getFirst("AssociationId"));
|
||||
p.getFirst("AssociationId"), Ec2QueryHandler.dryRun(p));
|
||||
XmlBuilder xml = startResponse("DisassociateClientVpnTargetNetwork")
|
||||
.elem("associationId", network.getAssociationId());
|
||||
return endResponse(status(xml, "disassociating"), "DisassociateClientVpnTargetNetwork");
|
||||
}
|
||||
|
||||
Response applySecurityGroups(MultivaluedMap<String, String> p, String region) {
|
||||
answerDryRunBeforeLookup(p);
|
||||
List<String> groups = clientVpn.applySecurityGroups(region, p.getFirst("ClientVpnEndpointId"),
|
||||
p.getFirst("VpcId"), getList(p, "SecurityGroupId"));
|
||||
XmlBuilder xml = startResponse("ApplySecurityGroupsToClientVpnTargetNetwork");
|
||||
@@ -168,11 +171,13 @@ class Ec2ClientVpnHandler {
|
||||
|
||||
Response authorize(MultivaluedMap<String, String> p, String region) {
|
||||
clientVpn.authorize(region, p.getFirst("ClientVpnEndpointId"), p.getFirst("TargetNetworkCidr"),
|
||||
p.getFirst("AccessGroupId"), boolParam(p, "AuthorizeAllGroups"), p.getFirst("Description"));
|
||||
p.getFirst("AccessGroupId"), boolParam(p, "AuthorizeAllGroups"), p.getFirst("Description"),
|
||||
Ec2QueryHandler.dryRun(p));
|
||||
return endResponse(status(startResponse("AuthorizeClientVpnIngress"), "authorizing"), "AuthorizeClientVpnIngress");
|
||||
}
|
||||
|
||||
Response describeAuthorizationRules(MultivaluedMap<String, String> p, String region) {
|
||||
answerDryRunBeforeLookup(p);
|
||||
String id = p.getFirst("ClientVpnEndpointId");
|
||||
List<Map.Entry<String, List<String>>> filters = filters(p, AUTHORIZATION_RULE_FILTERS);
|
||||
XmlBuilder xml = startResponse("DescribeClientVpnAuthorizationRules").start("authorizationRule");
|
||||
@@ -216,6 +221,7 @@ class Ec2ClientVpnHandler {
|
||||
}
|
||||
|
||||
Response describeRoutes(MultivaluedMap<String, String> p, String region) {
|
||||
answerDryRunBeforeLookup(p);
|
||||
String id = p.getFirst("ClientVpnEndpointId");
|
||||
List<Map.Entry<String, List<String>>> filters = filters(p, ROUTE_FILTERS);
|
||||
XmlBuilder xml = startResponse("DescribeClientVpnRoutes").start("routes");
|
||||
@@ -246,16 +252,26 @@ class Ec2ClientVpnHandler {
|
||||
|
||||
Response deleteRoute(MultivaluedMap<String, String> p, String region) {
|
||||
clientVpn.deleteRoute(region, p.getFirst("ClientVpnEndpointId"), p.getFirst("DestinationCidrBlock"),
|
||||
p.getFirst("TargetVpcSubnetId"));
|
||||
p.getFirst("TargetVpcSubnetId"), Ec2QueryHandler.dryRun(p));
|
||||
return endResponse(status(startResponse("DeleteClientVpnRoute"), "deleting"), "DeleteClientVpnRoute");
|
||||
}
|
||||
|
||||
Response exportClientConfiguration(MultivaluedMap<String, String> p, String region) {
|
||||
String configuration = clientVpn.exportClientConfiguration(region, p.getFirst("ClientVpnEndpointId"));
|
||||
String configuration = clientVpn.exportClientConfiguration(region, p.getFirst("ClientVpnEndpointId"),
|
||||
Ec2QueryHandler.dryRun(p));
|
||||
return endResponse(startResponse("ExportClientVpnClientConfiguration")
|
||||
.elem("clientConfiguration", configuration), "ExportClientVpnClientConfiguration");
|
||||
}
|
||||
|
||||
/**
|
||||
* AWS answers these calls' DryRun once the endpoint id is well formed and before the endpoint is
|
||||
* looked up, so a well-formed id that names nothing still gets DryRunOperation.
|
||||
*/
|
||||
private void answerDryRunBeforeLookup(MultivaluedMap<String, String> p) {
|
||||
clientVpn.requireWellFormedId(p.getFirst("ClientVpnEndpointId"));
|
||||
Ec2QueryHandler.checkDryRun(p);
|
||||
}
|
||||
|
||||
/** One endpoint as DescribeClientVpnEndpoints lists it, members in AWS's order. */
|
||||
private void endpoint(XmlBuilder xml, ClientVpnEndpoint endpoint, String region) {
|
||||
String id = endpoint.getClientVpnEndpointId();
|
||||
|
||||
@@ -172,7 +172,8 @@ public class Ec2ClientVpnService implements VpcDependencyProvider {
|
||||
String clientLoginBannerText, Boolean clientRouteEnforced,
|
||||
Boolean disconnectOnSessionTimeout) {}
|
||||
|
||||
public synchronized void modifyEndpoint(String region, String id, EndpointChange change) {
|
||||
public synchronized void modifyEndpoint(String region, String id, EndpointChange change,
|
||||
boolean dryRun) {
|
||||
ClientVpnEndpoint endpoint = require(region, id);
|
||||
String vpcId = change.vpcId() != null ? change.vpcId() : endpoint.getVpcId();
|
||||
if (change.vpcId() != null && !change.vpcId().equals(endpoint.getVpcId())) {
|
||||
@@ -189,6 +190,9 @@ public class Ec2ClientVpnService implements VpcDependencyProvider {
|
||||
securityGroups = securityGroupsOf(region, vpcId,
|
||||
change.securityGroupIds() != null ? change.securityGroupIds() : List.of());
|
||||
}
|
||||
if (dryRun) {
|
||||
throw Ec2Service.dryRunOperation();
|
||||
}
|
||||
if (change.serverCertificateArn() != null) {
|
||||
endpoint.setServerCertificateArn(change.serverCertificateArn());
|
||||
}
|
||||
@@ -239,12 +243,15 @@ public class Ec2ClientVpnService implements VpcDependencyProvider {
|
||||
}
|
||||
|
||||
/** Refused while target networks are associated, as AWS requires them disassociated first. */
|
||||
public synchronized void deleteEndpoint(String region, String id) {
|
||||
public synchronized void deleteEndpoint(String region, String id, boolean dryRun) {
|
||||
ClientVpnEndpoint endpoint = require(region, id);
|
||||
if (!endpoint.getTargetNetworks().isEmpty()) {
|
||||
throw new AwsException("IncorrectState",
|
||||
"Client VPN endpoint " + id + " has associated target networks; disassociate them first.", 400);
|
||||
}
|
||||
if (dryRun) {
|
||||
throw Ec2Service.dryRunOperation();
|
||||
}
|
||||
endpoints.delete(key(region, id));
|
||||
ec2.deleteTags(region, List.of(id), List.of());
|
||||
}
|
||||
@@ -328,12 +335,16 @@ public class Ec2ClientVpnService implements VpcDependencyProvider {
|
||||
}
|
||||
|
||||
/** Removes the association and every route through its subnet. */
|
||||
public synchronized TargetNetwork disassociate(String region, String id, String associationId) {
|
||||
public synchronized TargetNetwork disassociate(String region, String id, String associationId,
|
||||
boolean dryRun) {
|
||||
ClientVpnEndpoint endpoint = require(region, id);
|
||||
TargetNetwork network = endpoint.getTargetNetworks().stream()
|
||||
.filter(candidate -> candidate.getAssociationId().equals(associationId)).findFirst()
|
||||
.orElseThrow(() -> new AwsException("InvalidClientVpnAssociationId.NotFound",
|
||||
"Association " + associationId + " does not exist", 400));
|
||||
if (dryRun) {
|
||||
throw Ec2Service.dryRunOperation();
|
||||
}
|
||||
endpoint.setTargetNetworks(without(endpoint.getTargetNetworks(), candidate -> candidate == network));
|
||||
endpoint.setRoutes(without(endpoint.getRoutes(),
|
||||
route -> network.getSubnetId().equals(route.getTargetSubnet())));
|
||||
@@ -364,7 +375,7 @@ public class Ec2ClientVpnService implements VpcDependencyProvider {
|
||||
// ── Authorization rules ──
|
||||
|
||||
public synchronized void authorize(String region, String id, String targetNetworkCidr, String accessGroupId,
|
||||
Boolean authorizeAllGroups, String description) {
|
||||
Boolean authorizeAllGroups, String description, boolean dryRun) {
|
||||
ClientVpnEndpoint endpoint = require(region, id);
|
||||
requireCidr(targetNetworkCidr, "TargetNetworkCidr");
|
||||
boolean all = Boolean.TRUE.equals(authorizeAllGroups);
|
||||
@@ -377,6 +388,9 @@ public class Ec2ClientVpnService implements VpcDependencyProvider {
|
||||
if (exists) {
|
||||
throw invalid("An authorization rule for " + targetNetworkCidr + " already exists.");
|
||||
}
|
||||
if (dryRun) {
|
||||
throw Ec2Service.dryRunOperation();
|
||||
}
|
||||
AuthorizationRule rule = new AuthorizationRule();
|
||||
rule.setDestinationCidr(targetNetworkCidr);
|
||||
rule.setGroupId(all ? "" : accessGroupId);
|
||||
@@ -442,7 +456,8 @@ public class Ec2ClientVpnService implements VpcDependencyProvider {
|
||||
}
|
||||
|
||||
/** Removes the matching routes; a route an association added goes with the association only. */
|
||||
public synchronized void deleteRoute(String region, String id, String destinationCidr, String targetSubnet) {
|
||||
public synchronized void deleteRoute(String region, String id, String destinationCidr, String targetSubnet,
|
||||
boolean dryRun) {
|
||||
ClientVpnEndpoint endpoint = require(region, id);
|
||||
requireCidr(destinationCidr, "DestinationCidrBlock");
|
||||
List<Route> kept = without(endpoint.getRoutes(), route -> ORIGIN_ADD_ROUTE.equals(route.getOrigin())
|
||||
@@ -452,6 +467,9 @@ public class Ec2ClientVpnService implements VpcDependencyProvider {
|
||||
throw new AwsException("InvalidClientVpnRouteNotFound",
|
||||
"Route " + destinationCidr + " does not exist", 400);
|
||||
}
|
||||
if (dryRun) {
|
||||
throw Ec2Service.dryRunOperation();
|
||||
}
|
||||
endpoint.setRoutes(kept);
|
||||
endpoints.put(key(region, id), endpoint);
|
||||
}
|
||||
@@ -463,8 +481,12 @@ public class Ec2ClientVpnService implements VpcDependencyProvider {
|
||||
* server certificate's chain as the CA, and its common name to verify. The chain and name come
|
||||
* from the server certificate in ACM; a certificate ACM does not hold leaves them out.
|
||||
*/
|
||||
public String exportClientConfiguration(String region, String id) {
|
||||
public String exportClientConfiguration(String region, String id, boolean dryRun) {
|
||||
ClientVpnEndpoint endpoint = require(region, id);
|
||||
if (dryRun) {
|
||||
// Ahead of the ACM lookup, which settles and stores a pending certificate.
|
||||
throw Ec2Service.dryRunOperation();
|
||||
}
|
||||
Optional<Certificate> certificate = serverCertificate(endpoint, region);
|
||||
StringBuilder config = new StringBuilder()
|
||||
.append("client\n")
|
||||
@@ -500,11 +522,16 @@ public class Ec2ClientVpnService implements VpcDependencyProvider {
|
||||
|
||||
// ── Helpers ──
|
||||
|
||||
/** The endpoint an id names: AWS's error for a malformed id and for an unknown one. */
|
||||
public ClientVpnEndpoint require(String region, String id) {
|
||||
/** AWS's error for a malformed id, which comes ahead of a DryRun that is answered before the lookup. */
|
||||
public void requireWellFormedId(String id) {
|
||||
if (id == null || !ENDPOINT_ID.matcher(id).matches()) {
|
||||
throw invalid("ClientVpnEndpointId you provided is not valid");
|
||||
}
|
||||
}
|
||||
|
||||
/** The endpoint an id names: AWS's error for a malformed id and for an unknown one. */
|
||||
public ClientVpnEndpoint require(String region, String id) {
|
||||
requireWellFormedId(id);
|
||||
return endpoints.get(key(region, id)).orElseThrow(() -> new AwsException(
|
||||
"InvalidClientVpnEndpointId.NotFound", "Endpoint " + id + " does not exist", 400));
|
||||
}
|
||||
|
||||
@@ -124,10 +124,10 @@ public class Ec2QueryHandler {
|
||||
case "ModifyInstanceAttribute" -> handleModifyInstanceAttribute(params, region);
|
||||
case "ModifyInstanceMetadataOptions" -> handleModifyInstanceMetadataOptions(params, region);
|
||||
// EBS encryption defaults
|
||||
case "GetEbsEncryptionByDefault" -> handleGetEbsEncryptionByDefault(region);
|
||||
case "GetEbsEncryptionByDefault" -> handleGetEbsEncryptionByDefault(params, region);
|
||||
case "EnableEbsEncryptionByDefault" -> handleEnableEbsEncryptionByDefault(params, region);
|
||||
case "DisableEbsEncryptionByDefault" -> handleDisableEbsEncryptionByDefault(params, region);
|
||||
case "GetEbsDefaultKmsKeyId" -> handleGetEbsDefaultKmsKeyId(region);
|
||||
case "GetEbsDefaultKmsKeyId" -> handleGetEbsDefaultKmsKeyId(params, region);
|
||||
case "ModifyEbsDefaultKmsKeyId" -> handleModifyEbsDefaultKmsKeyId(params, region);
|
||||
case "ResetEbsDefaultKmsKeyId" -> handleResetEbsDefaultKmsKeyId(params, region);
|
||||
// AMI block public access
|
||||
@@ -203,9 +203,8 @@ public class Ec2QueryHandler {
|
||||
handleCreateTransitGatewayPeeringAttachment(params, region);
|
||||
case "DescribeTransitGatewayPeeringAttachments" ->
|
||||
handleDescribeTransitGatewayPeeringAttachments(params, region);
|
||||
case "AcceptTransitGatewayPeeringAttachment" -> peeringAttachmentResponse(
|
||||
"AcceptTransitGatewayPeeringAttachmentResponse", service.acceptTransitGatewayPeeringAttachment(
|
||||
region, params.getFirst("TransitGatewayAttachmentId")));
|
||||
case "AcceptTransitGatewayPeeringAttachment" ->
|
||||
handleAcceptTransitGatewayPeeringAttachment(params, region);
|
||||
case "DeleteTransitGatewayPeeringAttachment" -> peeringAttachmentResponse(
|
||||
"DeleteTransitGatewayPeeringAttachmentResponse", service.deleteTransitGatewayPeeringAttachment(
|
||||
region, params.getFirst("TransitGatewayAttachmentId")));
|
||||
@@ -477,7 +476,7 @@ public class Ec2QueryHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean parseOptionalBoolean(String value, String name) {
|
||||
private static Boolean parseOptionalBoolean(String value, String name) {
|
||||
if (value == null || value.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
@@ -688,7 +687,8 @@ public class Ec2QueryHandler {
|
||||
|
||||
// ─── EBS encryption defaults ─────────────────────────────────────────────
|
||||
|
||||
private Response handleGetEbsEncryptionByDefault(String region) {
|
||||
private Response handleGetEbsEncryptionByDefault(MultivaluedMap<String, String> p, String region) {
|
||||
checkDryRun(p);
|
||||
return ebsEncryptionBooleanResponse("GetEbsEncryptionByDefaultResponse",
|
||||
ebsEncryptionService.getEbsEncryptionByDefault(region));
|
||||
}
|
||||
@@ -705,7 +705,8 @@ public class Ec2QueryHandler {
|
||||
ebsEncryptionService.disableEbsEncryptionByDefault(region));
|
||||
}
|
||||
|
||||
private Response handleGetEbsDefaultKmsKeyId(String region) {
|
||||
private Response handleGetEbsDefaultKmsKeyId(MultivaluedMap<String, String> p, String region) {
|
||||
checkDryRun(p);
|
||||
return ebsKmsKeyResponse("GetEbsDefaultKmsKeyIdResponse",
|
||||
ebsEncryptionService.getEbsDefaultKmsKeyId(region));
|
||||
}
|
||||
@@ -2037,6 +2038,7 @@ public class Ec2QueryHandler {
|
||||
private Response handleDescribeVpcEndpointServices(MultivaluedMap<String, String> p, String region) {
|
||||
List<String> requested = getList(p, "ServiceName");
|
||||
List<Map.Entry<String, List<String>>> filters = getFiltersList(p);
|
||||
checkDryRun(p);
|
||||
List<String> azNames = service.describeAvailabilityZones(region, List.of(), List.of(), null).stream()
|
||||
.map(z -> z.get("zoneName")).toList();
|
||||
|
||||
@@ -2300,6 +2302,7 @@ public class Ec2QueryHandler {
|
||||
}
|
||||
|
||||
private Response handleDeleteFlowLogs(MultivaluedMap<String, String> p, String region) {
|
||||
checkDryRun(p);
|
||||
List<String> ids = getList(p, "FlowLogId");
|
||||
if (ids.isEmpty()) {
|
||||
ids = getList(p, "FlowLogIds.member");
|
||||
@@ -2465,14 +2468,14 @@ public class Ec2QueryHandler {
|
||||
return xmlResponse(xml.build());
|
||||
}
|
||||
|
||||
private void checkDryRun(MultivaluedMap<String, String> params) {
|
||||
static void checkDryRun(MultivaluedMap<String, String> params) {
|
||||
if (dryRun(params)) {
|
||||
throw Ec2Service.dryRunOperation();
|
||||
}
|
||||
}
|
||||
|
||||
/** The request's DryRun flag. A blank or non-boolean value is refused rather than read as false. */
|
||||
private boolean dryRun(MultivaluedMap<String, String> params) {
|
||||
static boolean dryRun(MultivaluedMap<String, String> params) {
|
||||
String value = params.getFirst("DryRun");
|
||||
if (value != null && value.isBlank()) {
|
||||
throw new AwsException("InvalidParameterValue", "DryRun is not a valid boolean.", 400);
|
||||
@@ -2782,6 +2785,7 @@ public class Ec2QueryHandler {
|
||||
private Response handleDescribePrefixLists(MultivaluedMap<String, String> p, String region) {
|
||||
List<String> ids = getList(p, "PrefixListId");
|
||||
List<Map.Entry<String, List<String>>> filters = getFiltersList(p);
|
||||
checkDryRun(p);
|
||||
List<PrefixList> lists = service.describePrefixLists(region, ids, filters);
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("DescribePrefixListsResponse", AwsNamespaces.EC2)
|
||||
@@ -2820,6 +2824,7 @@ public class Ec2QueryHandler {
|
||||
private Response handleDescribeManagedPrefixLists(MultivaluedMap<String, String> p, String region) {
|
||||
List<String> ids = getList(p, "PrefixListId");
|
||||
List<Map.Entry<String, List<String>>> filters = getFiltersList(p);
|
||||
checkDryRun(p);
|
||||
List<ManagedPrefixList> lists = service.describeManagedPrefixLists(region, ids, filters);
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("DescribeManagedPrefixListsResponse", AwsNamespaces.EC2)
|
||||
@@ -2893,6 +2898,7 @@ public class Ec2QueryHandler {
|
||||
}
|
||||
|
||||
private Response handleDescribeTransitGateways(MultivaluedMap<String, String> p, String region) {
|
||||
checkDryRun(p);
|
||||
List<TransitGateway> gateways = service.describeTransitGateways(
|
||||
region, getList(p, "TransitGatewayIds"), getFiltersList(p));
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
@@ -2925,7 +2931,7 @@ public class Ec2QueryHandler {
|
||||
}
|
||||
|
||||
private Response handleDeleteTransitGateway(MultivaluedMap<String, String> p, String region) {
|
||||
TransitGateway gateway = service.deleteTransitGateway(region, p.getFirst("TransitGatewayId"));
|
||||
TransitGateway gateway = service.deleteTransitGateway(region, p.getFirst("TransitGatewayId"), dryRun(p));
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("DeleteTransitGatewayResponse", AwsNamespaces.EC2)
|
||||
.elem("requestId", UUID.randomUUID().toString())
|
||||
@@ -2968,6 +2974,7 @@ public class Ec2QueryHandler {
|
||||
}
|
||||
|
||||
private Response handleDescribeTransitGatewayVpcAttachments(MultivaluedMap<String, String> p, String region) {
|
||||
checkDryRun(p);
|
||||
List<TransitGatewayVpcAttachment> attachments = service.describeTransitGatewayVpcAttachments(
|
||||
region, getList(p, "TransitGatewayAttachmentIds"), getFiltersList(p));
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
@@ -2987,6 +2994,7 @@ public class Ec2QueryHandler {
|
||||
* route table association shows up here and nowhere else.
|
||||
*/
|
||||
private Response handleDescribeTransitGatewayAttachments(MultivaluedMap<String, String> p, String region) {
|
||||
checkDryRun(p);
|
||||
List<TransitGatewayVpcAttachment> attachments = service.describeTransitGatewayVpcAttachments(
|
||||
region, getList(p, "TransitGatewayAttachmentIds"), getFiltersList(p));
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
@@ -3018,6 +3026,7 @@ public class Ec2QueryHandler {
|
||||
|
||||
/** floci does not yet support creating Connect attachments, so this is always an empty list. */
|
||||
private Response handleDescribeTransitGatewayConnects(MultivaluedMap<String, String> p, String region) {
|
||||
checkDryRun(p);
|
||||
service.describeTransitGatewayConnects(region, getList(p, "TransitGatewayAttachmentIds"), getFiltersList(p));
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("DescribeTransitGatewayConnectsResponse", AwsNamespaces.EC2)
|
||||
@@ -3069,14 +3078,24 @@ public class Ec2QueryHandler {
|
||||
parseTagsForResource(p, "transit-gateway-attachment")));
|
||||
}
|
||||
|
||||
private Response handleAcceptTransitGatewayPeeringAttachment(MultivaluedMap<String, String> p, String region) {
|
||||
// AWS answers DryRun once the id is well formed and before it looks the attachment up.
|
||||
Ec2Service.requirePeeringAttachmentIdForm(p.getFirst("TransitGatewayAttachmentId"));
|
||||
checkDryRun(p);
|
||||
return peeringAttachmentResponse("AcceptTransitGatewayPeeringAttachmentResponse",
|
||||
service.acceptTransitGatewayPeeringAttachment(region, p.getFirst("TransitGatewayAttachmentId")));
|
||||
}
|
||||
|
||||
private Response handleDescribeTransitGatewayPeeringAttachments(MultivaluedMap<String, String> p,
|
||||
String region) {
|
||||
checkDryRun(p);
|
||||
List<TransitGatewayPeeringAttachment> attachments = service.describeTransitGatewayPeeringAttachments(
|
||||
region, getList(p, "TransitGatewayAttachmentIds"), getFiltersList(p));
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("DescribeTransitGatewayPeeringAttachmentsResponse", AwsNamespaces.EC2)
|
||||
.elem("requestId", UUID.randomUUID().toString())
|
||||
.start("transitGatewayPeeringAttachments");
|
||||
for (TransitGatewayPeeringAttachment attachment : service.describeTransitGatewayPeeringAttachments(
|
||||
region, getList(p, "TransitGatewayAttachmentIds"), getFiltersList(p))) {
|
||||
for (TransitGatewayPeeringAttachment attachment : attachments) {
|
||||
xml.start("item").raw(peeringAttachmentXml(attachment)).end("item");
|
||||
}
|
||||
xml.end("transitGatewayPeeringAttachments").end("DescribeTransitGatewayPeeringAttachmentsResponse");
|
||||
@@ -3138,6 +3157,7 @@ public class Ec2QueryHandler {
|
||||
}
|
||||
|
||||
private Response handleDescribeTransitGatewayRouteTables(MultivaluedMap<String, String> p, String region) {
|
||||
checkDryRun(p);
|
||||
List<TransitGatewayRouteTable> routeTables = service.describeTransitGatewayRouteTables(
|
||||
region, getList(p, "TransitGatewayRouteTableIds"), getFiltersList(p));
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
@@ -3165,7 +3185,8 @@ public class Ec2QueryHandler {
|
||||
|
||||
private Response handleAssociateTransitGatewayRouteTable(MultivaluedMap<String, String> p, String region) {
|
||||
TransitGatewayVpcAttachment attachment = service.associateTransitGatewayRouteTable(
|
||||
region, p.getFirst("TransitGatewayRouteTableId"), p.getFirst("TransitGatewayAttachmentId"));
|
||||
region, p.getFirst("TransitGatewayRouteTableId"), p.getFirst("TransitGatewayAttachmentId"),
|
||||
dryRun(p));
|
||||
// Verified live: the call reports the transitional state even though the association is
|
||||
// already recorded.
|
||||
return xmlResponse(new XmlBuilder()
|
||||
@@ -3220,7 +3241,8 @@ public class Ec2QueryHandler {
|
||||
private Response handleDisableTransitGatewayRouteTablePropagation(
|
||||
MultivaluedMap<String, String> p, String region) {
|
||||
TransitGatewayRouteTablePropagation propagation = service.disableTransitGatewayRouteTablePropagation(
|
||||
region, p.getFirst("TransitGatewayRouteTableId"), p.getFirst("TransitGatewayAttachmentId"));
|
||||
region, p.getFirst("TransitGatewayRouteTableId"), p.getFirst("TransitGatewayAttachmentId"),
|
||||
dryRun(p));
|
||||
return xmlResponse(new XmlBuilder()
|
||||
.start("DisableTransitGatewayRouteTablePropagationResponse", AwsNamespaces.EC2)
|
||||
.elem("requestId", UUID.randomUUID().toString())
|
||||
@@ -3251,7 +3273,8 @@ public class Ec2QueryHandler {
|
||||
p.getFirst("TransitGatewayRouteTableId"),
|
||||
p.getFirst("DestinationCidrBlock"),
|
||||
p.getFirst("TransitGatewayAttachmentId"),
|
||||
Boolean.parseBoolean(p.getFirst("Blackhole")));
|
||||
Boolean.parseBoolean(p.getFirst("Blackhole")),
|
||||
dryRun(p));
|
||||
return xmlResponse(new XmlBuilder()
|
||||
.start("CreateTransitGatewayRouteResponse", AwsNamespaces.EC2)
|
||||
.elem("requestId", UUID.randomUUID().toString())
|
||||
@@ -3302,6 +3325,7 @@ public class Ec2QueryHandler {
|
||||
private Response handleExportTransitGatewayRoutes(MultivaluedMap<String, String> p, String region) {
|
||||
String s3Location = service.exportTransitGatewayRoutes(
|
||||
region, p.getFirst("TransitGatewayRouteTableId"), p.getFirst("S3Bucket"));
|
||||
checkDryRun(p);
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("ExportTransitGatewayRoutesResponse", AwsNamespaces.EC2)
|
||||
.elem("requestId", UUID.randomUUID().toString())
|
||||
@@ -4003,6 +4027,7 @@ public class Ec2QueryHandler {
|
||||
if (noName && noId) {
|
||||
throw new AwsException("MissingParameter", "The request must contain the parameter KeyName", 400);
|
||||
}
|
||||
checkDryRun(p);
|
||||
KeyPair deleted = service.deleteKeyPair(region, keyName, keyPairId);
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("DeleteKeyPairResponse", AwsNamespaces.EC2)
|
||||
@@ -4484,6 +4509,7 @@ public class Ec2QueryHandler {
|
||||
private Response handleDescribeRouteTables(MultivaluedMap<String, String> p, String region) {
|
||||
List<String> ids = getList(p, "RouteTableId");
|
||||
List<Map.Entry<String, List<String>>> filters = getFiltersList(p);
|
||||
checkDryRun(p);
|
||||
List<RouteTable> rts = service.describeRouteTables(region, ids, filters);
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("DescribeRouteTablesResponse", AwsNamespaces.EC2)
|
||||
@@ -4711,6 +4737,7 @@ public class Ec2QueryHandler {
|
||||
private Response handleDescribeNetworkAcls(MultivaluedMap<String, String> p, String region) {
|
||||
List<String> ids = getList(p, "NetworkAclId");
|
||||
List<Map.Entry<String, List<String>>> filters = getFiltersList(p);
|
||||
checkDryRun(p);
|
||||
List<NetworkAcl> acls = service.describeNetworkAcls(region, ids, filters);
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("DescribeNetworkAclsResponse", AwsNamespaces.EC2)
|
||||
@@ -4793,6 +4820,7 @@ public class Ec2QueryHandler {
|
||||
private Response handleDescribeNatGateways(MultivaluedMap<String, String> p, String region) {
|
||||
List<String> natGatewayIds = getList(p, "NatGatewayId");
|
||||
List<Map.Entry<String, List<String>>> filters = getFiltersList(p);
|
||||
checkDryRun(p);
|
||||
List<NatGateway> natGateways = service.describeNatGateways(region, natGatewayIds, filters);
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("DescribeNatGatewaysResponse", AwsNamespaces.EC2)
|
||||
@@ -4937,6 +4965,7 @@ public class Ec2QueryHandler {
|
||||
private Response handleDescribeCapacityReservations(MultivaluedMap<String, String> p, String region) {
|
||||
List<String> ids = getList(p, "CapacityReservationId");
|
||||
List<Map.Entry<String, List<String>>> filters = getFiltersList(p);
|
||||
checkDryRun(p);
|
||||
List<CapacityReservation> reservations = service.describeCapacityReservations(region, ids, filters);
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("DescribeCapacityReservationsResponse", AwsNamespaces.EC2)
|
||||
@@ -4956,7 +4985,8 @@ public class Ec2QueryHandler {
|
||||
intOrNull(p, "InstanceCount"),
|
||||
instantOrNull(p, "EndDate"),
|
||||
p.getFirst("EndDateType"),
|
||||
p.getFirst("InstanceMatchCriteria"));
|
||||
p.getFirst("InstanceMatchCriteria"),
|
||||
dryRun(p));
|
||||
return booleanResponse("ModifyCapacityReservation");
|
||||
}
|
||||
|
||||
@@ -5166,7 +5196,7 @@ public class Ec2QueryHandler {
|
||||
}
|
||||
|
||||
private Response handleDisassociateAddress(MultivaluedMap<String, String> p, String region) {
|
||||
service.disassociateAddress(region, p.getFirst("AssociationId"));
|
||||
service.disassociateAddress(region, p.getFirst("AssociationId"), dryRun(p));
|
||||
return booleanResponse("DisassociateAddress");
|
||||
}
|
||||
|
||||
@@ -5241,6 +5271,7 @@ public class Ec2QueryHandler {
|
||||
}
|
||||
|
||||
private Response handleDescribeRegions(MultivaluedMap<String, String> p, String region) {
|
||||
checkDryRun(p);
|
||||
// The partition the request is scoped to, not the region's own: a region no partition
|
||||
// publishes is served in the deployment's partition, where its ARNs are minted too.
|
||||
AwsPartition partition = AwsPartitions.byId(regionResolver.partitionForRegion(region));
|
||||
@@ -5265,6 +5296,7 @@ public class Ec2QueryHandler {
|
||||
}
|
||||
|
||||
private Response handleDescribeAccountAttributes(MultivaluedMap<String, String> p, String region) {
|
||||
checkDryRun(p);
|
||||
Map<String, String> attrs = service.describeAccountAttributes(region);
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("DescribeAccountAttributesResponse", AwsNamespaces.EC2)
|
||||
@@ -5284,6 +5316,7 @@ public class Ec2QueryHandler {
|
||||
|
||||
private Response handleDescribeInstanceTypes(MultivaluedMap<String, String> p, String region) {
|
||||
List<String> typeNames = getList(p, "InstanceType");
|
||||
checkDryRun(p);
|
||||
List<Map<String, Object>> types = service.describeInstanceTypes(typeNames);
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("DescribeInstanceTypesResponse", AwsNamespaces.EC2)
|
||||
@@ -5453,7 +5486,7 @@ public class Ec2QueryHandler {
|
||||
|
||||
private Response handleDeleteLaunchTemplate(MultivaluedMap<String, String> p, String region) {
|
||||
LaunchTemplate launchTemplate = service.deleteLaunchTemplate(
|
||||
region, p.getFirst("LaunchTemplateId"), p.getFirst("LaunchTemplateName"));
|
||||
region, p.getFirst("LaunchTemplateId"), p.getFirst("LaunchTemplateName"), dryRun(p));
|
||||
XmlBuilder xml = new XmlBuilder()
|
||||
.start("DeleteLaunchTemplateResponse", AwsNamespaces.EC2)
|
||||
.elem("requestId", UUID.randomUUID().toString())
|
||||
@@ -5493,6 +5526,7 @@ public class Ec2QueryHandler {
|
||||
// ─── Network Interface handlers ───────────────────────────────────────────
|
||||
|
||||
private Response handleDescribeNetworkInterfaces(MultivaluedMap<String, String> p, String region) {
|
||||
checkDryRun(p);
|
||||
List<String> ids = getList(p, "NetworkInterfaceId");
|
||||
List<Map.Entry<String, List<String>>> filters = getFiltersList(p);
|
||||
|
||||
|
||||
@@ -3044,6 +3044,11 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
* the returned object carries the settled state for the same reason creation does.
|
||||
*/
|
||||
public TransitGateway deleteTransitGateway(String region, String transitGatewayId) {
|
||||
return deleteTransitGateway(region, transitGatewayId, false);
|
||||
}
|
||||
|
||||
/** As above; with {@code dryRun} every check is made and the gateway is left available. */
|
||||
public TransitGateway deleteTransitGateway(String region, String transitGatewayId, boolean dryRun) {
|
||||
// Outermost first: the attachment check below and a concurrent attachment create have to
|
||||
// agree on who goes first.
|
||||
synchronized (attachmentTopologyLock(region)) {
|
||||
@@ -3075,6 +3080,9 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
throw new AwsException("IncorrectState", transitGatewayId
|
||||
+ " has non-deleted Peering Attachments: " + String.join(", ", peered) + ".", 400);
|
||||
}
|
||||
if (dryRun) {
|
||||
throw dryRunOperation();
|
||||
}
|
||||
live.stream()
|
||||
.filter(attachment -> isGateway(attachment.getAccepterTgwInfo(), region, transitGatewayId))
|
||||
.forEach(attachment -> rejectPendingPeering(attachment.getTransitGatewayAttachmentId()));
|
||||
@@ -3409,6 +3417,15 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
}
|
||||
}
|
||||
|
||||
/** The id's presence and form, which AWS checks ahead of a DryRun answered before the lookup. */
|
||||
static void requirePeeringAttachmentIdForm(String attachmentId) {
|
||||
if (!isSet(attachmentId)) {
|
||||
throw new AwsException("MissingParameter",
|
||||
"The request must contain the parameter TransitGatewayAttachmentId.", 400);
|
||||
}
|
||||
requireWellFormedAttachmentId(attachmentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verified live: an id of the wrong shape is rejected before any lookup, and the message does
|
||||
* not echo it back, unlike the transit gateway's equivalent.
|
||||
@@ -3561,11 +3578,7 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
* {@link #allVpcPeeringConnections} uses.
|
||||
*/
|
||||
private OwnedPeeringAttachment getRequiredPeeringAttachment(String region, String attachmentId) {
|
||||
if (!isSet(attachmentId)) {
|
||||
throw new AwsException("MissingParameter",
|
||||
"The request must contain the parameter TransitGatewayAttachmentId.", 400);
|
||||
}
|
||||
requireWellFormedAttachmentId(attachmentId);
|
||||
requirePeeringAttachmentIdForm(attachmentId);
|
||||
return findPeeringAttachment(attachmentId)
|
||||
.filter(owned -> isPartyTo(owned.attachment(), callerAccountId(), region))
|
||||
.orElseThrow(() -> peeringAttachmentNotFound(attachmentId));
|
||||
@@ -3727,6 +3740,12 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
/** An attachment associates with exactly one route table, so a second attempt is refused. */
|
||||
public TransitGatewayVpcAttachment associateTransitGatewayRouteTable(
|
||||
String region, String routeTableId, String attachmentId) {
|
||||
return associateTransitGatewayRouteTable(region, routeTableId, attachmentId, false);
|
||||
}
|
||||
|
||||
/** As above; with {@code dryRun} the checks are made and nothing is associated. */
|
||||
public TransitGatewayVpcAttachment associateTransitGatewayRouteTable(
|
||||
String region, String routeTableId, String attachmentId, boolean dryRun) {
|
||||
synchronized (attachmentTopologyLock(region)) {
|
||||
TransitGatewayRouteTable routeTable = getRequiredTransitGatewayRouteTable(region, routeTableId);
|
||||
TransitGatewayVpcAttachment attachment =
|
||||
@@ -3735,6 +3754,9 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
throw new AwsException("Resource.AlreadyAssociated", "Transit Gateway Attachment "
|
||||
+ attachmentId + " is already associated to a route table.", 400);
|
||||
}
|
||||
if (dryRun) {
|
||||
throw dryRunOperation();
|
||||
}
|
||||
attachment.setAssociationRouteTableId(routeTableId);
|
||||
attachment.setAssociationState("associated");
|
||||
transitGatewayVpcAttachments.put(key(region, attachmentId), attachment);
|
||||
@@ -3795,6 +3817,12 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
|
||||
public TransitGatewayRouteTablePropagation disableTransitGatewayRouteTablePropagation(
|
||||
String region, String routeTableId, String attachmentId) {
|
||||
return disableTransitGatewayRouteTablePropagation(region, routeTableId, attachmentId, false);
|
||||
}
|
||||
|
||||
/** As above; with {@code dryRun} the checks are made and the propagation is left enabled. */
|
||||
public TransitGatewayRouteTablePropagation disableTransitGatewayRouteTablePropagation(
|
||||
String region, String routeTableId, String attachmentId, boolean dryRun) {
|
||||
synchronized (attachmentTopologyLock(region)) {
|
||||
TransitGatewayRouteTable routeTable = getRequiredTransitGatewayRouteTable(region, routeTableId);
|
||||
requireAttachmentOfSameGateway(region, routeTable, attachmentId);
|
||||
@@ -3803,6 +3831,9 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
.orElseThrow(() -> new AwsException("InvalidparameterValue", "Propagation "
|
||||
+ attachmentId + " does not exist in Transit Gateway Route Table "
|
||||
+ routeTableId + ".", 400));
|
||||
if (dryRun) {
|
||||
throw dryRunOperation();
|
||||
}
|
||||
transitGatewayPropagations.delete(propagationKey(region, routeTableId, attachmentId));
|
||||
propagation.setState("disabled");
|
||||
return propagation;
|
||||
@@ -3838,6 +3869,13 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
public TransitGatewayRoute createTransitGatewayRoute(String region, String routeTableId,
|
||||
String destinationCidrBlock, String attachmentId,
|
||||
boolean blackhole) {
|
||||
return createTransitGatewayRoute(region, routeTableId, destinationCidrBlock, attachmentId, blackhole, false);
|
||||
}
|
||||
|
||||
/** As above; with {@code dryRun} the checks are made and no route is written. */
|
||||
public TransitGatewayRoute createTransitGatewayRoute(String region, String routeTableId,
|
||||
String destinationCidrBlock, String attachmentId,
|
||||
boolean blackhole, boolean dryRun) {
|
||||
synchronized (attachmentTopologyLock(region)) {
|
||||
getRequiredTransitGatewayRouteTable(region, routeTableId);
|
||||
if (destinationCidrBlock == null || destinationCidrBlock.isBlank()) {
|
||||
@@ -3863,6 +3901,9 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
route.setResourceId(attachment.getVpcId());
|
||||
route.setResourceType("vpc");
|
||||
}
|
||||
if (dryRun) {
|
||||
throw dryRunOperation();
|
||||
}
|
||||
transitGatewayRoutes.put(routeKey(region, routeTableId, destinationCidrBlock), route);
|
||||
return route;
|
||||
}
|
||||
@@ -11170,9 +11211,17 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
}
|
||||
|
||||
public LaunchTemplate deleteLaunchTemplate(String region, String id, String name) {
|
||||
return deleteLaunchTemplate(region, id, name, false);
|
||||
}
|
||||
|
||||
/** As above; with {@code dryRun} the template is resolved and then answered with DryRunOperation, kept. */
|
||||
public LaunchTemplate deleteLaunchTemplate(String region, String id, String name, boolean dryRun) {
|
||||
ensureDefaultResources(region);
|
||||
LaunchTemplate launchTemplate = findLaunchTemplate(region, id, name);
|
||||
synchronized (launchTemplate) {
|
||||
if (dryRun) {
|
||||
throw dryRunOperation();
|
||||
}
|
||||
launchTemplates.delete(key(region, launchTemplate.getLaunchTemplateId()));
|
||||
removeTags(region, launchTemplate.getLaunchTemplateId());
|
||||
return launchTemplate;
|
||||
@@ -12819,7 +12868,15 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
* (the AWS provider's own update path) never asks for that, so nothing here re-checks it.
|
||||
*/
|
||||
public CapacityReservation modifyCapacityReservation(String region, String capacityReservationId,
|
||||
Integer instanceCount, java.time.Instant endDate, String endDateType, String instanceMatchCriteria) {
|
||||
Integer instanceCount, Instant endDate, String endDateType, String instanceMatchCriteria) {
|
||||
return modifyCapacityReservation(region, capacityReservationId, instanceCount, endDate, endDateType,
|
||||
instanceMatchCriteria, false);
|
||||
}
|
||||
|
||||
/** As above; with {@code dryRun} the checks are made and the reservation is left as it is. */
|
||||
public CapacityReservation modifyCapacityReservation(String region, String capacityReservationId,
|
||||
Integer instanceCount, Instant endDate, String endDateType, String instanceMatchCriteria,
|
||||
boolean dryRun) {
|
||||
synchronized (capacityReservationLock) {
|
||||
ensureDefaultResources(region);
|
||||
reconcileCapacityMembership(region);
|
||||
@@ -12857,6 +12914,9 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
if (instanceMatchCriteria != null) {
|
||||
reservation.setInstanceMatchCriteria(instanceMatchCriteria);
|
||||
}
|
||||
if (dryRun) {
|
||||
throw dryRunOperation();
|
||||
}
|
||||
capacityReservations.put(key(region, capacityReservationId), reservation);
|
||||
return reservation;
|
||||
}
|
||||
@@ -15067,6 +15127,11 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
}
|
||||
|
||||
public void disassociateAddress(String region, String associationId) {
|
||||
disassociateAddress(region, associationId, false);
|
||||
}
|
||||
|
||||
/** As above; with {@code dryRun} the checks are made and the address stays associated. */
|
||||
public void disassociateAddress(String region, String associationId, boolean dryRun) {
|
||||
ensureDefaultResources(region);
|
||||
// Under the lock NAT create and delete take, so the gateway check and the clear see the
|
||||
// same association.
|
||||
@@ -15081,6 +15146,9 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
+ " belongs to a NAT gateway and cannot be disassociated; delete the NAT gateway.",
|
||||
400);
|
||||
}
|
||||
if (dryRun) {
|
||||
throw dryRunOperation();
|
||||
}
|
||||
// An address a retained interface carries names no instance; the instance that
|
||||
// interface is attached to now holds it.
|
||||
String instanceId = addr.getInstanceId() != null ? addr.getInstanceId()
|
||||
@@ -15109,6 +15177,10 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
return;
|
||||
}
|
||||
}
|
||||
// An association that is not there is no error, as for the real call.
|
||||
if (dryRun) {
|
||||
throw dryRunOperation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.floci.aws.services.ec2;
|
||||
|
||||
import io.floci.aws.core.common.AwsException;
|
||||
import io.floci.aws.core.storage.AccountAwareStorageBackend;
|
||||
import io.floci.aws.services.acm.AcmService;
|
||||
import io.floci.aws.services.ec2.model.ClientVpnEndpoint;
|
||||
@@ -15,7 +16,9 @@ import static io.floci.aws.testing.Ec2ServiceFixtures.ACCOUNT;
|
||||
import static io.floci.aws.testing.Ec2ServiceFixtures.mockModeService;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verifyNoInteractions;
|
||||
|
||||
/**
|
||||
* CreateClientVpnEndpoint's ClientToken: a retry with the token returns the endpoint the first call
|
||||
@@ -26,8 +29,9 @@ class Ec2ClientVpnClientTokenTest {
|
||||
|
||||
private static final String REGION = "us-east-1";
|
||||
|
||||
private final AcmService acm = mock(AcmService.class);
|
||||
private final Ec2ClientVpnService vpn = new Ec2ClientVpnService(
|
||||
AccountAwareStorageBackend.<ClientVpnEndpoint>inMemory(ACCOUNT), mockModeService(), mock(AcmService.class));
|
||||
AccountAwareStorageBackend.<ClientVpnEndpoint>inMemory(ACCOUNT), mockModeService(), acm);
|
||||
|
||||
@Test
|
||||
void aRetryWithTheSameTokenReturnsTheFirstEndpoint() {
|
||||
@@ -48,6 +52,17 @@ class Ec2ClientVpnClientTokenTest {
|
||||
assertEquals(Stream.of(first, second).sorted().toList(), endpointIds());
|
||||
}
|
||||
|
||||
/** The ACM lookup settles and stores a pending certificate, which a DryRun must not cause. */
|
||||
@Test
|
||||
void anExportDryRunLeavesTheServerCertificateUntouched() {
|
||||
String id = createEndpoint(null);
|
||||
|
||||
AwsException answer = assertThrows(AwsException.class, () -> vpn.exportClientConfiguration(REGION, id, true));
|
||||
|
||||
assertEquals("DryRunOperation", answer.getErrorCode());
|
||||
verifyNoInteractions(acm);
|
||||
}
|
||||
|
||||
/** A certificate-authenticated endpoint with every optional member left to AWS's default. */
|
||||
private String createEndpoint(String clientToken) {
|
||||
ClientVpnEndpoint.Authentication certificate = new ClientVpnEndpoint.Authentication();
|
||||
|
||||
@@ -0,0 +1,374 @@
|
||||
package io.floci.aws.services.ec2;
|
||||
|
||||
import io.floci.aws.testing.QueryRequests;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.restassured.path.xml.XmlPath;
|
||||
import io.restassured.response.Response;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
/**
|
||||
* DryRun on the EBS encryption defaults, Transit Gateway, Client VPN, key pair, launch template and
|
||||
* describe calls is answered with DryRunOperation and HTTP 412 before the resource is resolved, so a
|
||||
* well-formed id that does not exist still gets it, and the request changes nothing.
|
||||
*/
|
||||
@QuarkusTest
|
||||
class Ec2ControlPlaneDryRunIntegrationTest {
|
||||
|
||||
private static final AtomicLong ACCOUNTS = new AtomicLong(726200000000L);
|
||||
private static final String TGW = "tgw-0123456789abcdef0";
|
||||
private static final String ATTACHMENT = "tgw-attach-0123456789abcdef0";
|
||||
private static final String ROUTE_TABLE = "tgw-rtb-0123456789abcdef0";
|
||||
private static final String CLIENT_VPN = "cvpn-endpoint-0123456789abcdef0";
|
||||
|
||||
private final String account = Long.toString(ACCOUNTS.incrementAndGet());
|
||||
|
||||
/** Calls with nothing to resolve, and calls AWS answers before it looks the resource up. */
|
||||
@ParameterizedTest
|
||||
@CsvSource(delimiter = '|', value = {
|
||||
"GetEbsEncryptionByDefault|",
|
||||
"GetEbsDefaultKmsKeyId|",
|
||||
"DescribeAccountAttributes|",
|
||||
"DescribeCapacityReservations|",
|
||||
"DescribeTransitGateways|",
|
||||
"DescribeTransitGatewayAttachments|",
|
||||
"DescribeTransitGatewayConnects|",
|
||||
"DescribeTransitGatewayPeeringAttachments|",
|
||||
"DescribeTransitGatewayVpcAttachments|",
|
||||
"DescribeTransitGatewayRouteTables|",
|
||||
"DescribeTransitGateways|TransitGatewayIds.1=" + TGW,
|
||||
"DescribeCapacityReservations|CapacityReservationId.1=cr-0123456789abcdef0",
|
||||
"DescribeNetworkInterfaces|NetworkInterfaceId.1=eni-0123456789abcdef0",
|
||||
"DescribeClientVpnEndpoints|",
|
||||
"DescribeClientVpnEndpoints|ClientVpnEndpointId.1=" + CLIENT_VPN,
|
||||
"DescribeInstanceTypes|",
|
||||
"DescribePrefixLists|",
|
||||
"DescribeManagedPrefixLists|",
|
||||
"DescribeRegions|",
|
||||
"DescribeRouteTables|",
|
||||
"DescribeVpcEndpointServices|",
|
||||
"DescribeNatGateways|",
|
||||
"DescribeNetworkAcls|",
|
||||
"DescribeNetworkInterfaces|",
|
||||
"DeleteKeyPair|KeyName=no-such-key",
|
||||
"DisassociateAddress|AssociationId=eipassoc-0123456789abcdef0",
|
||||
"DeleteFlowLogs|FlowLogId.1=fl-0123456789abcdef0",
|
||||
"AcceptTransitGatewayPeeringAttachment|TransitGatewayAttachmentId=" + ATTACHMENT,
|
||||
"ApplySecurityGroupsToClientVpnTargetNetwork|ClientVpnEndpointId=" + CLIENT_VPN
|
||||
+ "&VpcId=vpc-0123456789abcdef0&SecurityGroupId.1=sg-0123456789abcdef0",
|
||||
"DescribeClientVpnTargetNetworks|ClientVpnEndpointId=" + CLIENT_VPN,
|
||||
"DescribeClientVpnAuthorizationRules|ClientVpnEndpointId=" + CLIENT_VPN,
|
||||
"DescribeClientVpnRoutes|ClientVpnEndpointId=" + CLIENT_VPN
|
||||
})
|
||||
void aDryRunIsAnsweredWithDryRunOperation(String action, String query) {
|
||||
dryRun(action, query).then()
|
||||
.statusCode(412)
|
||||
.body("Response.Errors.Error.Code", equalTo("DryRunOperation"))
|
||||
.body("Response.Errors.Error.Message",
|
||||
equalTo("Request would have succeeded, but DryRun flag is set."));
|
||||
}
|
||||
|
||||
/** A dry run the real call would refuse keeps the real call's error. */
|
||||
@ParameterizedTest
|
||||
@CsvSource(delimiter = '|', value = {
|
||||
"DeleteTransitGateway|TransitGatewayId=" + TGW + "|InvalidTransitGatewayID.NotFound",
|
||||
"AssociateTransitGatewayRouteTable|TransitGatewayRouteTableId=" + ROUTE_TABLE
|
||||
+ "&TransitGatewayAttachmentId=" + ATTACHMENT + "|InvalidRouteTableID.NotFound",
|
||||
"DisableTransitGatewayRouteTablePropagation|TransitGatewayRouteTableId=" + ROUTE_TABLE
|
||||
+ "&TransitGatewayAttachmentId=" + ATTACHMENT + "|InvalidRouteTableID.NotFound",
|
||||
"CreateTransitGatewayRoute|TransitGatewayRouteTableId=" + ROUTE_TABLE
|
||||
+ "&DestinationCidrBlock=10.0.0.0/16&TransitGatewayAttachmentId=" + ATTACHMENT
|
||||
+ "|InvalidRouteTableID.NotFound",
|
||||
"AcceptTransitGatewayPeeringAttachment|TransitGatewayAttachmentId=not-an-attachment"
|
||||
+ "|InvalidTransitGatewayAttachmentID.Malformed",
|
||||
"ModifyClientVpnEndpoint|ClientVpnEndpointId=" + CLIENT_VPN + "&Description=d"
|
||||
+ "|InvalidClientVpnEndpointId.NotFound",
|
||||
"DeleteClientVpnEndpoint|ClientVpnEndpointId=" + CLIENT_VPN + "|InvalidClientVpnEndpointId.NotFound",
|
||||
"DisassociateClientVpnTargetNetwork|ClientVpnEndpointId=" + CLIENT_VPN
|
||||
+ "&AssociationId=cvpn-assoc-0123456789abcdef0|InvalidClientVpnEndpointId.NotFound",
|
||||
"AuthorizeClientVpnIngress|ClientVpnEndpointId=" + CLIENT_VPN
|
||||
+ "&TargetNetworkCidr=10.0.0.0/16&AuthorizeAllGroups=true|InvalidClientVpnEndpointId.NotFound",
|
||||
"DeleteClientVpnRoute|ClientVpnEndpointId=" + CLIENT_VPN
|
||||
+ "&DestinationCidrBlock=10.0.0.0/16|InvalidClientVpnEndpointId.NotFound",
|
||||
"ExportClientVpnClientConfiguration|ClientVpnEndpointId=" + CLIENT_VPN
|
||||
+ "|InvalidClientVpnEndpointId.NotFound",
|
||||
"DescribeClientVpnTargetNetworks|ClientVpnEndpointId=not-an-endpoint|InvalidParameterValue",
|
||||
"DeleteLaunchTemplate|LaunchTemplateName=no-such-template|InvalidLaunchTemplateName.NotFoundException",
|
||||
"ModifyCapacityReservation|CapacityReservationId=cr-0123456789abcdef0&InstanceCount=2"
|
||||
+ "|InvalidCapacityReservationId.NotFound",
|
||||
"DeleteKeyPair||MissingParameter",
|
||||
"ExportTransitGatewayRoutes|TransitGatewayRouteTableId=" + ROUTE_TABLE + "&S3Bucket=b"
|
||||
+ "|InvalidRouteTableID.NotFound"
|
||||
})
|
||||
void aDryRunTheRealCallWouldRefuseKeepsItsError(String action, String query, String errorCode) {
|
||||
dryRun(action, query).then()
|
||||
.statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo(errorCode));
|
||||
// The real call, without DryRun, is refused the same way.
|
||||
QueryRequests.request(account, "ec2", action).formParams(params(query)).post("/").then()
|
||||
.statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo(errorCode));
|
||||
}
|
||||
|
||||
/** A DryRun value that is not a boolean is refused as one. */
|
||||
@ParameterizedTest
|
||||
@CsvSource({
|
||||
"DeleteTransitGateway, maybe",
|
||||
"DeleteTransitGateway, ''",
|
||||
"DeleteKeyPair, maybe",
|
||||
"DeleteLaunchTemplate, ''",
|
||||
"DescribeRegions, maybe",
|
||||
"DescribeNatGateways, ''",
|
||||
"ModifyClientVpnEndpoint, maybe"
|
||||
})
|
||||
void aDryRunValueThatIsNotABooleanIsRefused(String action, String value) {
|
||||
QueryRequests.request(account, "ec2", action).formParam("DryRun", value)
|
||||
.formParam("TransitGatewayId", TGW).formParam("KeyName", "k")
|
||||
.formParam("LaunchTemplateName", "t").formParam("ClientVpnEndpointId", CLIENT_VPN)
|
||||
.post("/").then()
|
||||
.statusCode(400)
|
||||
.body("Response.Errors.Error.Code", equalTo("InvalidParameterValue"))
|
||||
.body("Response.Errors.Error.Message", equalTo("DryRun is not a valid boolean."));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aDryRunDeleteLeavesTheTransitGatewayAvailable() {
|
||||
String id = ec2("CreateTransitGateway")
|
||||
.getString("CreateTransitGatewayResponse.transitGateway.transitGatewayId");
|
||||
dryRun("DeleteTransitGateway", "TransitGatewayId=" + id).then().statusCode(412);
|
||||
assertEquals("available", ec2("DescribeTransitGateways", "TransitGatewayId.1", id)
|
||||
.getString("DescribeTransitGatewaysResponse.transitGatewaySet.item.state"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aDryRunDeleteLeavesTheKeyPairAndTheLaunchTemplate() {
|
||||
ec2("CreateKeyPair", "KeyName", "dry-run-key");
|
||||
dryRun("DeleteKeyPair", "KeyName=dry-run-key").then().statusCode(412);
|
||||
assertEquals("dry-run-key", ec2("DescribeKeyPairs", "KeyName.1", "dry-run-key")
|
||||
.getString("DescribeKeyPairsResponse.keySet.item.keyName"));
|
||||
|
||||
ec2("CreateLaunchTemplate", "LaunchTemplateName", "dry-run-template",
|
||||
"LaunchTemplateData.InstanceType", "t3.micro");
|
||||
dryRun("DeleteLaunchTemplate", "LaunchTemplateName=dry-run-template").then().statusCode(412);
|
||||
assertEquals("dry-run-template", ec2("DescribeLaunchTemplates", "LaunchTemplateName.1", "dry-run-template")
|
||||
.getString("DescribeLaunchTemplatesResponse.launchTemplates.item.launchTemplateName"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aDryRunAssociateLeavesTheAttachmentUnassociated() {
|
||||
String gateway = ec2("CreateTransitGateway", "Options.DefaultRouteTableAssociation", "disable",
|
||||
"Options.DefaultRouteTablePropagation", "disable")
|
||||
.getString("CreateTransitGatewayResponse.transitGateway.transitGatewayId");
|
||||
String attachment = vpcAttachment(gateway, "10.40");
|
||||
String routeTable = ec2("CreateTransitGatewayRouteTable", "TransitGatewayId", gateway)
|
||||
.getString("CreateTransitGatewayRouteTableResponse.transitGatewayRouteTable"
|
||||
+ ".transitGatewayRouteTableId");
|
||||
|
||||
dryRun("AssociateTransitGatewayRouteTable", "TransitGatewayRouteTableId=" + routeTable
|
||||
+ "&TransitGatewayAttachmentId=" + attachment).then().statusCode(412);
|
||||
|
||||
assertEquals(0, ec2("GetTransitGatewayRouteTableAssociations", "TransitGatewayRouteTableId", routeTable)
|
||||
.getList("GetTransitGatewayRouteTableAssociationsResponse.associations.item").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aDryRunCreateRouteWritesNoRoute() {
|
||||
String gateway = ec2("CreateTransitGateway")
|
||||
.getString("CreateTransitGatewayResponse.transitGateway.transitGatewayId");
|
||||
String routeTable = ec2("CreateTransitGatewayRouteTable", "TransitGatewayId", gateway)
|
||||
.getString("CreateTransitGatewayRouteTableResponse.transitGatewayRouteTable"
|
||||
+ ".transitGatewayRouteTableId");
|
||||
|
||||
dryRun("CreateTransitGatewayRoute", "TransitGatewayRouteTableId=" + routeTable
|
||||
+ "&DestinationCidrBlock=10.50.0.0/16&Blackhole=true").then().statusCode(412);
|
||||
|
||||
assertEquals(0, ec2("SearchTransitGatewayRoutes", "TransitGatewayRouteTableId", routeTable,
|
||||
"Filter.1.Name", "type", "Filter.1.Value.1", "static")
|
||||
.getList("SearchTransitGatewayRoutesResponse.routeSet.item").size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aDryRunModifyAndDeleteLeaveTheClientVpnEndpointAsItWas() {
|
||||
String endpoint = ec2("CreateClientVpnEndpoint", "ClientCidrBlock", "10.100.0.0/16",
|
||||
"ServerCertificateArn", "arn:aws:acm:us-east-1:000000000000:certificate/dry-run",
|
||||
"Authentication.1.Type", "certificate-authentication",
|
||||
"Authentication.1.MutualAuthentication.ClientRootCertificateChainArn",
|
||||
"arn:aws:acm:us-east-1:000000000000:certificate/dry-run-client",
|
||||
"ConnectionLogOptions.Enabled", "false", "Description", "original")
|
||||
.getString("CreateClientVpnEndpointResponse.clientVpnEndpointId");
|
||||
|
||||
dryRun("ModifyClientVpnEndpoint", "ClientVpnEndpointId=" + endpoint + "&Description=changed")
|
||||
.then().statusCode(412);
|
||||
dryRun("DeleteClientVpnEndpoint", "ClientVpnEndpointId=" + endpoint).then().statusCode(412);
|
||||
|
||||
XmlPath described = ec2("DescribeClientVpnEndpoints", "ClientVpnEndpointId.1", endpoint);
|
||||
assertEquals("original", described.getString("DescribeClientVpnEndpointsResponse.clientVpnEndpoint"
|
||||
+ ".item.description"));
|
||||
assertEquals(endpoint, described.getString("DescribeClientVpnEndpointsResponse.clientVpnEndpoint"
|
||||
+ ".item.clientVpnEndpointId"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aDryRunModifyLeavesTheStoredCapacityReservationAsItWas() {
|
||||
String reservation = ec2("CreateCapacityReservation", "InstanceType", "t3.micro", "InstancePlatform",
|
||||
"Linux/UNIX", "AvailabilityZone", "us-east-1a", "InstanceCount", "1")
|
||||
.getString("CreateCapacityReservationResponse.capacityReservation.capacityReservationId");
|
||||
|
||||
dryRun("ModifyCapacityReservation", "CapacityReservationId=" + reservation + "&InstanceCount=5")
|
||||
.then().statusCode(412);
|
||||
|
||||
assertEquals("1", ec2("DescribeCapacityReservations", "CapacityReservationId.1", reservation)
|
||||
.getString("DescribeCapacityReservationsResponse.capacityReservationSet.item.totalInstanceCount"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aDryRunDisassociateLeavesTheAddressAssociated() {
|
||||
String allocation = ec2("AllocateAddress").getString("AllocateAddressResponse.allocationId");
|
||||
String instance = ec2("RunInstances", "ImageId", "ami-0abcdef1234567890", "InstanceType", "t3.micro",
|
||||
"MinCount", "1", "MaxCount", "1").getString("RunInstancesResponse.instancesSet.item.instanceId");
|
||||
String association = ec2("AssociateAddress", "AllocationId", allocation, "InstanceId", instance)
|
||||
.getString("AssociateAddressResponse.associationId");
|
||||
|
||||
dryRun("DisassociateAddress", "AssociationId=" + association).then().statusCode(412);
|
||||
|
||||
assertEquals(association, ec2("DescribeAddresses", "AllocationId.1", allocation)
|
||||
.getString("DescribeAddressesResponse.addressesSet.item.associationId"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aDryRunDeleteLeavesTheFlowLog() {
|
||||
String vpc = ec2("CreateVpc", "CidrBlock", "10.41.0.0/16").getString("CreateVpcResponse.vpc.vpcId");
|
||||
String flowLog = ec2("CreateFlowLogs", "ResourceType", "VPC", "ResourceId.1", vpc, "TrafficType", "ALL",
|
||||
"LogDestinationType", "s3", "LogDestination", "arn:aws:s3:::dry-run-flow-logs")
|
||||
.getString("CreateFlowLogsResponse.flowLogIdSet.item");
|
||||
|
||||
dryRun("DeleteFlowLogs", "FlowLogId.1=" + flowLog).then().statusCode(412);
|
||||
|
||||
assertEquals(flowLog, ec2("DescribeFlowLogs", "FlowLogId.1", flowLog)
|
||||
.getString("DescribeFlowLogsResponse.flowLogSet.item.flowLogId"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aDryRunDisableLeavesThePropagationEnabled() {
|
||||
String gateway = ec2("CreateTransitGateway", "Options.DefaultRouteTableAssociation", "disable",
|
||||
"Options.DefaultRouteTablePropagation", "disable")
|
||||
.getString("CreateTransitGatewayResponse.transitGateway.transitGatewayId");
|
||||
String attachment = vpcAttachment(gateway, "10.42");
|
||||
String routeTable = ec2("CreateTransitGatewayRouteTable", "TransitGatewayId", gateway)
|
||||
.getString("CreateTransitGatewayRouteTableResponse.transitGatewayRouteTable"
|
||||
+ ".transitGatewayRouteTableId");
|
||||
ec2("EnableTransitGatewayRouteTablePropagation", "TransitGatewayRouteTableId", routeTable,
|
||||
"TransitGatewayAttachmentId", attachment);
|
||||
|
||||
dryRun("DisableTransitGatewayRouteTablePropagation", "TransitGatewayRouteTableId=" + routeTable
|
||||
+ "&TransitGatewayAttachmentId=" + attachment).then().statusCode(412);
|
||||
|
||||
assertEquals(attachment, ec2("GetTransitGatewayRouteTablePropagations", "TransitGatewayRouteTableId",
|
||||
routeTable).getString("GetTransitGatewayRouteTablePropagationsResponse"
|
||||
+ ".transitGatewayRouteTablePropagations.item.transitGatewayAttachmentId"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aDryRunAcceptLeavesThePeeringPendingAcceptance() {
|
||||
String gateway = ec2("CreateTransitGateway")
|
||||
.getString("CreateTransitGatewayResponse.transitGateway.transitGatewayId");
|
||||
String peer = ec2("CreateTransitGateway")
|
||||
.getString("CreateTransitGatewayResponse.transitGateway.transitGatewayId");
|
||||
String attachment = ec2("CreateTransitGatewayPeeringAttachment", "TransitGatewayId", gateway,
|
||||
"PeerTransitGatewayId", peer, "PeerAccountId", account, "PeerRegion", "us-east-1")
|
||||
.getString("CreateTransitGatewayPeeringAttachmentResponse"
|
||||
+ ".transitGatewayPeeringAttachment.transitGatewayAttachmentId");
|
||||
|
||||
dryRun("AcceptTransitGatewayPeeringAttachment", "TransitGatewayAttachmentId=" + attachment)
|
||||
.then().statusCode(412);
|
||||
|
||||
assertEquals("pendingAcceptance", ec2("DescribeTransitGatewayPeeringAttachments",
|
||||
"TransitGatewayAttachmentIds.1", attachment).getString(
|
||||
"DescribeTransitGatewayPeeringAttachmentsResponse.transitGatewayPeeringAttachments.item.state"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aDryRunClientVpnCallLeavesTheEndpointAsItWas() {
|
||||
String vpc = ec2("CreateVpc", "CidrBlock", "10.43.0.0/16").getString("CreateVpcResponse.vpc.vpcId");
|
||||
String subnet = ec2("CreateSubnet", "VpcId", vpc, "CidrBlock", "10.43.1.0/24", "AvailabilityZone",
|
||||
"us-east-1a").getString("CreateSubnetResponse.subnet.subnetId");
|
||||
String group = ec2("CreateSecurityGroup", "GroupName", "dry-run-sg", "GroupDescription", "d", "VpcId", vpc)
|
||||
.getString("CreateSecurityGroupResponse.groupId");
|
||||
String arn = "arn:aws:acm:us-east-1:000000000000:certificate/dry-run";
|
||||
String endpoint = ec2("CreateClientVpnEndpoint", "ClientCidrBlock", "10.101.0.0/16",
|
||||
"ServerCertificateArn", arn, "Authentication.1.Type", "certificate-authentication",
|
||||
"Authentication.1.MutualAuthentication.ClientRootCertificateChainArn", arn,
|
||||
"ConnectionLogOptions.Enabled", "false", "VpcId", vpc)
|
||||
.getString("CreateClientVpnEndpointResponse.clientVpnEndpointId");
|
||||
String association = ec2("AssociateClientVpnTargetNetwork", "ClientVpnEndpointId", endpoint,
|
||||
"SubnetId", subnet).getString("AssociateClientVpnTargetNetworkResponse.associationId");
|
||||
ec2("CreateClientVpnRoute", "ClientVpnEndpointId", endpoint, "DestinationCidrBlock", "192.168.0.0/16",
|
||||
"TargetVpcSubnetId", subnet);
|
||||
String before = clientVpnState(endpoint);
|
||||
|
||||
String id = "ClientVpnEndpointId=" + endpoint;
|
||||
dryRun("AuthorizeClientVpnIngress", id + "&TargetNetworkCidr=10.43.0.0/16&AuthorizeAllGroups=true")
|
||||
.then().statusCode(412);
|
||||
dryRun("DeleteClientVpnRoute", id + "&DestinationCidrBlock=192.168.0.0/16&TargetVpcSubnetId=" + subnet)
|
||||
.then().statusCode(412);
|
||||
dryRun("ApplySecurityGroupsToClientVpnTargetNetwork", id + "&VpcId=" + vpc + "&SecurityGroupId.1=" + group)
|
||||
.then().statusCode(412);
|
||||
dryRun("DisassociateClientVpnTargetNetwork", id + "&AssociationId=" + association).then().statusCode(412);
|
||||
|
||||
assertEquals(before, clientVpnState(endpoint));
|
||||
assertEquals(1, ec2("DescribeClientVpnTargetNetworks", "ClientVpnEndpointId", endpoint)
|
||||
.getList("DescribeClientVpnTargetNetworksResponse.clientVpnTargetNetworks.item").size());
|
||||
}
|
||||
|
||||
/** The endpoint, its security groups, authorization rules and routes, without the request ids. */
|
||||
private String clientVpnState(String endpoint) {
|
||||
return String.join("\n",
|
||||
body("DescribeClientVpnEndpoints", "ClientVpnEndpointId.1", endpoint),
|
||||
body("DescribeClientVpnTargetNetworks", "ClientVpnEndpointId", endpoint),
|
||||
body("DescribeClientVpnAuthorizationRules", "ClientVpnEndpointId", endpoint),
|
||||
body("DescribeClientVpnRoutes", "ClientVpnEndpointId", endpoint));
|
||||
}
|
||||
|
||||
private String body(String action, String... params) {
|
||||
return QueryRequests.request(account, "ec2", action, params).post("/").then().statusCode(200).extract()
|
||||
.asString().replaceAll("<requestId>[^<]*</requestId>", "");
|
||||
}
|
||||
|
||||
private String vpcAttachment(String gateway, String prefix) {
|
||||
String vpc = ec2("CreateVpc", "CidrBlock", prefix + ".0.0/16").getString("CreateVpcResponse.vpc.vpcId");
|
||||
String subnet = ec2("CreateSubnet", "VpcId", vpc, "CidrBlock", prefix + ".1.0/24", "AvailabilityZone",
|
||||
"us-east-1a").getString("CreateSubnetResponse.subnet.subnetId");
|
||||
return ec2("CreateTransitGatewayVpcAttachment", "TransitGatewayId", gateway, "VpcId", vpc,
|
||||
"SubnetIds.1", subnet).getString("CreateTransitGatewayVpcAttachmentResponse"
|
||||
+ ".transitGatewayVpcAttachment.transitGatewayAttachmentId");
|
||||
}
|
||||
|
||||
private Response dryRun(String action, String query) {
|
||||
return QueryRequests.request(account, "ec2", action).formParams(params(query))
|
||||
.formParam("DryRun", "true").post("/");
|
||||
}
|
||||
|
||||
private static Map<String, String> params(String query) {
|
||||
Map<String, String> params = new LinkedHashMap<>();
|
||||
if (query != null) {
|
||||
for (String pair : query.split("&")) {
|
||||
String[] kv = pair.split("=", 2);
|
||||
params.put(kv[0], kv[1]);
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
private XmlPath ec2(String action, String... params) {
|
||||
return QueryRequests.request(account, "ec2", action, params).post("/").then().statusCode(200)
|
||||
.extract().xmlPath();
|
||||
}
|
||||
}
|
||||
@@ -164,6 +164,21 @@ class Ec2DryRunIamIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void aKeyPairDryRunNeedsTheCallersCurrentPermission() throws Exception {
|
||||
try (Ec2Client admin = AwsTestClients.create(Ec2Client.builder(), "test", Region.US_EAST_1, endpoint)) {
|
||||
String name = "dry-run-iam-key";
|
||||
admin.createKeyPair(r -> r.keyName(name));
|
||||
try {
|
||||
assertADryRunNeedsTheCallersCurrentPermission("DeleteKeyPair",
|
||||
() -> admin.describeKeyPairs(r -> r.keyNames(name)).keyPairs(),
|
||||
caller -> caller.deleteKeyPair(r -> r.keyName(name).dryRun(true)));
|
||||
} finally {
|
||||
admin.deleteKeyPair(r -> r.keyName(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A caller the policy allows {@code action} gets DryRunOperation for {@code dryRun}, and UnauthorizedOperation
|
||||
* once the policy is removed; {@code state} reads the same before and after.
|
||||
|
||||
@@ -664,6 +664,48 @@ class Ec2QueryHandlerTest {
|
||||
verifyNoInteractions(service);
|
||||
}
|
||||
|
||||
/**
|
||||
* A dry-run describe answers before it calls the service: the service call seeds the account's default
|
||||
* resources (and, for capacity reservations, reconciles state), which a dry run must not do.
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"DescribeRouteTables", "DescribeNetworkAcls", "DescribeNatGateways",
|
||||
"DescribeNetworkInterfaces", "DescribeCapacityReservations", "DescribeInstanceTypes",
|
||||
"DescribePrefixLists", "DescribeManagedPrefixLists", "DescribeVpcEndpointServices",
|
||||
"DescribeTransitGateways", "DescribeTransitGatewayVpcAttachments", "DescribeTransitGatewayAttachments",
|
||||
"DescribeTransitGatewayConnects", "DescribeTransitGatewayPeeringAttachments",
|
||||
"DescribeTransitGatewayRouteTables"})
|
||||
void aDryRunDescribeAnswersBeforeCallingTheService(String action) {
|
||||
Ec2Service service = mock(Ec2Service.class);
|
||||
MultivaluedMap<String, String> params = new MultivaluedHashMap<>();
|
||||
params.putSingle("DryRun", "true");
|
||||
|
||||
Response response = handler(service).handle(action, params, "us-east-1");
|
||||
|
||||
assertEquals(412, response.getStatus());
|
||||
assertTrue(response.getEntity().toString().contains("<Code>DryRunOperation</Code>"));
|
||||
verifyNoInteractions(service);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aDryRunDescribeClientVpnEndpointsAnswersBeforeLookingUpTheEndpoint() {
|
||||
Ec2Service service = mock(Ec2Service.class);
|
||||
Ec2ClientVpnService clientVpn = mock(Ec2ClientVpnService.class);
|
||||
MultivaluedMap<String, String> params = new MultivaluedHashMap<>();
|
||||
params.putSingle("DryRun", "true");
|
||||
params.putSingle("ClientVpnEndpointId.1", "cvpn-endpoint-0123456789abcdef0");
|
||||
|
||||
Response response = new Ec2QueryHandler(
|
||||
service, mock(EmulatorConfig.class), mock(FlowLogService.class),
|
||||
mock(Ec2EbsEncryptionService.class), mock(Ec2BlockPublicAccessService.class),
|
||||
mock(Ec2IpamService.class), new RegionResolver("us-east-1", "000000000000"), clientVpn)
|
||||
.handle("DescribeClientVpnEndpoints", params, "us-east-1");
|
||||
|
||||
assertEquals(412, response.getStatus());
|
||||
assertTrue(response.getEntity().toString().contains("<Code>DryRunOperation</Code>"));
|
||||
verifyNoInteractions(clientVpn);
|
||||
}
|
||||
|
||||
@Test
|
||||
void aSecurityGroupDryRunWithoutAVpcIdNeedsTheDefaultVpcToExist() {
|
||||
Ec2Service service = mock(Ec2Service.class);
|
||||
|
||||
Reference in new issue
Block a user