diff --git a/api/v1beta1/awsmachine_conversion.go b/api/v1beta1/awsmachine_conversion.go index 1f09d43515..55856591a9 100644 --- a/api/v1beta1/awsmachine_conversion.go +++ b/api/v1beta1/awsmachine_conversion.go @@ -39,7 +39,6 @@ func (src *AWSMachine) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.InstanceMetadataOptions = restored.Spec.InstanceMetadataOptions dst.Spec.PlacementGroupName = restored.Spec.PlacementGroupName dst.Spec.PrivateDNSName = restored.Spec.PrivateDNSName - dst.Spec.VPC = restored.Spec.VPC dst.Spec.SecurityGroupOverrides = restored.Spec.SecurityGroupOverrides return nil @@ -89,7 +88,6 @@ func (r *AWSMachineTemplate) ConvertTo(dstRaw conversion.Hub) error { dst.Spec.Template.Spec.InstanceMetadataOptions = restored.Spec.Template.Spec.InstanceMetadataOptions dst.Spec.Template.Spec.PlacementGroupName = restored.Spec.Template.Spec.PlacementGroupName dst.Spec.Template.Spec.PrivateDNSName = restored.Spec.Template.Spec.PrivateDNSName - dst.Spec.Template.Spec.VPC = restored.Spec.Template.Spec.VPC dst.Spec.Template.Spec.SecurityGroupOverrides = restored.Spec.Template.Spec.SecurityGroupOverrides return nil diff --git a/api/v1beta1/zz_generated.conversion.go b/api/v1beta1/zz_generated.conversion.go index af11dc0332..ec3859c7f1 100644 --- a/api/v1beta1/zz_generated.conversion.go +++ b/api/v1beta1/zz_generated.conversion.go @@ -1390,7 +1390,6 @@ func autoConvert_v1beta2_AWSMachineSpec_To_v1beta1_AWSMachineSpec(in *v1beta2.AW } else { out.AdditionalSecurityGroups = nil } - // WARNING: in.VPC requires manual conversion: does not exist in peer-type if in.Subnet != nil { in, out := &in.Subnet, &out.Subnet *out = new(AWSResourceReference) diff --git a/api/v1beta2/awsmachine_types.go b/api/v1beta2/awsmachine_types.go index 332f561c5f..dad3bb0575 100644 --- a/api/v1beta2/awsmachine_types.go +++ b/api/v1beta2/awsmachine_types.go @@ -109,11 +109,6 @@ type AWSMachineSpec struct { // +optional AdditionalSecurityGroups []AWSResourceReference `json:"additionalSecurityGroups,omitempty"` - // VPC is a reference to the VPC to use when picking a subnet to use for this - // instance. Only valid if the subnet (id or filters) is also specified. - // +optional - VPC *AWSResourceReference `json:"vpc,omitempty"` - // Subnet is a reference to the subnet to use for this instance. If not specified, // the cluster subnet will be used. // +optional diff --git a/api/v1beta2/zz_generated.deepcopy.go b/api/v1beta2/zz_generated.deepcopy.go index 49b6658bbe..b3cd28d608 100644 --- a/api/v1beta2/zz_generated.deepcopy.go +++ b/api/v1beta2/zz_generated.deepcopy.go @@ -695,11 +695,6 @@ func (in *AWSMachineSpec) DeepCopyInto(out *AWSMachineSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } - if in.VPC != nil { - in, out := &in.VPC, &out.VPC - *out = new(AWSResourceReference) - (*in).DeepCopyInto(*out) - } if in.Subnet != nil { in, out := &in.Subnet, &out.Subnet *out = new(AWSResourceReference) diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml index e23cf8547c..f8e31edb56 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachines.yaml @@ -912,36 +912,6 @@ spec: built-in support for gzip-compressed user data user data stored in aws secret manager is always gzip-compressed. type: boolean - vpc: - description: VPC is a reference to the VPC to use when picking a subnet - to use for this instance. Only valid if the subnet (id or filters) - is also specified. - properties: - filters: - description: 'Filters is a set of key/value pairs used to identify - a resource They are applied according to the rules defined by - the AWS API: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Filtering.html' - items: - description: Filter is a filter used to identify an AWS resource. - properties: - name: - description: Name of the filter. Filter names are case-sensitive. - type: string - values: - description: Values includes one or more filter values. - Filter values are case-sensitive. - items: - type: string - type: array - required: - - name - - values - type: object - type: array - id: - description: ID of resource - type: string - type: object required: - instanceType type: object diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml index 8c75ad94ce..5ae1afd3a6 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_awsmachinetemplates.yaml @@ -876,38 +876,6 @@ spec: cloud-init has built-in support for gzip-compressed user data user data stored in aws secret manager is always gzip-compressed. type: boolean - vpc: - description: VPC is a reference to the VPC to use when picking - a subnet to use for this instance. Only valid if the subnet - (id or filters) is also specified. - properties: - filters: - description: 'Filters is a set of key/value pairs used - to identify a resource They are applied according to - the rules defined by the AWS API: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_Filtering.html' - items: - description: Filter is a filter used to identify an - AWS resource. - properties: - name: - description: Name of the filter. Filter names are - case-sensitive. - type: string - values: - description: Values includes one or more filter - values. Filter values are case-sensitive. - items: - type: string - type: array - required: - - name - - values - type: object - type: array - id: - description: ID of resource - type: string - type: object required: - instanceType type: object diff --git a/controllers/awsmachine_controller_test.go b/controllers/awsmachine_controller_test.go index 6e4b26ffda..01122cad0e 100644 --- a/controllers/awsmachine_controller_test.go +++ b/controllers/awsmachine_controller_test.go @@ -530,10 +530,6 @@ func mockedCreateSecretCall(s *mock_services.MockSecretInterfaceMockRecorder) { func mockedCreateInstanceCalls(m *mocks.MockEC2APIMockRecorder) { m.DescribeInstancesWithContext(context.TODO(), gomock.Eq(&ec2.DescribeInstancesInput{ Filters: []*ec2.Filter{ - { - Name: aws.String("vpc-id"), - Values: aws.StringSlice([]string{""}), - }, { Name: aws.String("tag:sigs.k8s.io/cluster-api-provider-aws/cluster/test-cluster"), Values: aws.StringSlice([]string{"owned"}), @@ -642,10 +638,6 @@ func mockedCreateInstanceCalls(m *mocks.MockEC2APIMockRecorder) { Name: aws.String("state"), Values: aws.StringSlice([]string{"pending", "available"}), }, - { - Name: aws.String("vpc-id"), - Values: aws.StringSlice([]string{""}), - }, { Name: aws.String("subnet-id"), Values: aws.StringSlice([]string{"subnet-1"}), diff --git a/docs/book/src/topics/bring-your-own-aws-infrastructure.md b/docs/book/src/topics/bring-your-own-aws-infrastructure.md index 4841425158..bd157fa28f 100644 --- a/docs/book/src/topics/bring-your-own-aws-infrastructure.md +++ b/docs/book/src/topics/bring-your-own-aws-infrastructure.md @@ -120,6 +120,30 @@ spec: Users may either specify `failureDomain` on the Machine or MachineDeployment objects, _or_ users may explicitly specify subnet IDs on the AWSMachine or AWSMachineTemplate objects. If both are specified, the subnet ID is used and the `failureDomain` is ignored. +### Placing EC2 Instances in Specific External VPCs + +CAPA clusters are deployed within a single VPC, but it's possible to place machines that live in external VPCs. For this kind of configuration, we assume that all the VPCs have the ability to communicate, either through external peering, a transit gateway, or some other mechanism already established outside of CAPA. CAPA will not create a tunnel or manage the network configuration for any secondary VPCs. + +The AWSMachineTemplate `subnet` field allows specifying filters or specific subnet ids for worker machine placement. If the filters or subnet id is specified in a secondary VPC, CAPA will place the machine in that VPC and subnet. + +```yaml +spec: + template: + spec: + subnet: + filters: + name: "vpc-id" + values: + - "secondary-vpc-id" + securityGroupOverrides: + node: sg-04e870a3507a5ad2c5c8c2 + node-eks-additional: sg-04e870a3507a5ad2c5c8c1 +``` + +#### Caveats/Notes + +CAPA helpfully creates security groups for various roles in the cluster and automatically attaches them to workers. However, security groups are tied to a specific VPC, so workers placed in a VPC outside of the cluster will need to have these security groups created by some external process first and set in the `securityGroupOverrides` field, otherwise the ec2 creation will fail. + ### Security Groups To use existing security groups for instances for a cluster, add this to the AWSCluster specification: @@ -147,6 +171,15 @@ spec: - ... ``` +It's also possible to override the cluster security groups for an individual AWSMachine or AWSMachineTemplate: + +```yaml +spec: + SecurityGroupOverrides: + node: sg-04e870a3507a5ad2c5c8c2 + node-eks-additional: sg-04e870a3507a5ad2c5c8c1 +``` + ### Control Plane Load Balancer The cluster control plane is accessed through a Classic ELB. By default, Cluster API creates the Classic ELB. To use an existing Classic ELB, add its name to the AWSCluster specification: diff --git a/pkg/cloud/services/ec2/instances.go b/pkg/cloud/services/ec2/instances.go index c514702bfb..ad9a746a8d 100644 --- a/pkg/cloud/services/ec2/instances.go +++ b/pkg/cloud/services/ec2/instances.go @@ -43,13 +43,8 @@ import ( func (s *Service) GetRunningInstanceByTags(scope *scope.MachineScope) (*infrav1.Instance, error) { s.scope.Debug("Looking for existing machine instance by tags") - vpcID, err := s.getVPCID(scope) - if err != nil { - return nil, err - } input := &ec2.DescribeInstancesInput{ Filters: []*ec2.Filter{ - filter.EC2.VPC(vpcID), filter.EC2.ClusterOwned(s.scope.Name()), filter.EC2.Name(scope.Name()), filter.EC2.InstanceStates(ec2.InstanceStateNamePending, ec2.InstanceStateNameRunning), @@ -312,13 +307,6 @@ func (s *Service) findSubnet(scope *scope.MachineScope) (string, error) { criteria := []*ec2.Filter{ filter.EC2.SubnetStates(ec2.SubnetStatePending, ec2.SubnetStateAvailable), } - if !scope.IsExternallyManaged() { - vpcID, err := s.getVPCID(scope) - if err != nil { - return "", fmt.Errorf("failed to lookup vpc for subnets: %w", err) - } - criteria = append(criteria, filter.EC2.VPC(vpcID)) - } if scope.AWSMachine.Spec.Subnet.ID != nil { criteria = append(criteria, &ec2.Filter{Name: aws.String("subnet-id"), Values: aws.StringSlice([]string{*scope.AWSMachine.Spec.Subnet.ID})}) } @@ -353,6 +341,11 @@ func (s *Service) findSubnet(scope *scope.MachineScope) (string, error) { } filtered = append(filtered, subnet) } + // prefer a subnet in the cluster VPC if multiple match + clusterVPC := s.scope.VPC().ID + sort.SliceStable(filtered, func(i, j int) bool { + return strings.Compare(*filtered[i].VpcId, clusterVPC) > strings.Compare(*filtered[j].VpcId, clusterVPC) + }) if len(filtered) == 0 { errMessage = fmt.Sprintf("failed to run machine %q, found %d subnets matching criteria but post-filtering failed.", scope.Name(), len(subnets)) + errMessage @@ -403,30 +396,6 @@ func (s *Service) findSubnet(scope *scope.MachineScope) (string, error) { } } -func (s *Service) getVPCID(scope *scope.MachineScope) (string, error) { - if scope.AWSMachine.Spec.VPC == nil { - return s.scope.VPC().ID, nil - } - if scope.AWSMachine.Spec.VPC.ID != nil { - return *scope.AWSMachine.Spec.VPC.ID, nil - } - filters := make([]*ec2.Filter, 0, len(scope.AWSMachine.Spec.VPC.Filters)) - for _, filter := range scope.AWSMachine.Spec.VPC.Filters { - filters = append(filters, &ec2.Filter{ - Name: aws.String(filter.Name), - Values: aws.StringSlice(filter.Values), - }) - } - out, err := s.EC2Client.DescribeVpcsWithContext(context.TODO(), &ec2.DescribeVpcsInput{Filters: filters}) - if err != nil { - return "", err - } - if out != nil && len(out.Vpcs) == 1 { - return *out.Vpcs[0].VpcId, nil - } - return "", fmt.Errorf("ambigious VPC filters, only one VPC expected, got %v", out) -} - // getFilteredSubnets fetches subnets filtered based on the criteria passed. func (s *Service) getFilteredSubnets(criteria ...*ec2.Filter) ([]*ec2.Subnet, error) { out, err := s.EC2Client.DescribeSubnetsWithContext(context.TODO(), &ec2.DescribeSubnetsInput{Filters: criteria}) diff --git a/pkg/cloud/services/ec2/instances_test.go b/pkg/cloud/services/ec2/instances_test.go index c294cf17ac..f68e4a5f5e 100644 --- a/pkg/cloud/services/ec2/instances_test.go +++ b/pkg/cloud/services/ec2/instances_test.go @@ -549,14 +549,14 @@ func TestCreateInstance(t *testing.T) { }, }, { - name: "with vpc and sg roles", - machine: clusterv1.Machine{ + name: "when multiple subnets match filters, subnets in the cluster vpc are preferred", + machine: &clusterv1.Machine{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{"set": "node"}, }, Spec: clusterv1.MachineSpec{ Bootstrap: clusterv1.Bootstrap{ - DataSecretName: pointer.String("bootstrap-data"), + DataSecretName: aws.String("bootstrap-data"), }, FailureDomain: aws.String("us-east-1c"), }, @@ -566,9 +566,6 @@ func TestCreateInstance(t *testing.T) { ID: aws.String("abc"), }, InstanceType: "m5.2xlarge", - VPC: &infrav1.AWSResourceReference{ - ID: aws.String("vpc-bar"), - }, Subnet: &infrav1.AWSResourceReference{ Filters: []infrav1.Filter{ { @@ -577,9 +574,6 @@ func TestCreateInstance(t *testing.T) { }, }, }, - SecurityGroupOverrides: map[infrav1.SecurityGroupRole]string{ - infrav1.SecurityGroupNode: "4", - }, UncompressedUserData: &isUncompressedFalse, }, awsCluster: &infrav1.AWSCluster{ @@ -605,11 +599,6 @@ func TestCreateInstance(t *testing.T) { AvailabilityZone: "us-east-1c", IsPublic: false, }, - infrav1.SubnetSpec{ - ID: "subnet-3-public", - AvailabilityZone: "us-east-1c", - IsPublic: true, - }, }, }, }, @@ -652,14 +641,7 @@ func TestCreateInstance(t *testing.T) { }, nil) m.DescribeSubnetsWithContext(context.TODO(), gomock.Eq(&ec2.DescribeSubnetsInput{ Filters: []*ec2.Filter{ - { - Name: aws.String("state"), - Values: aws.StringSlice([]string{ec2.VpcStatePending, ec2.VpcStateAvailable}), - }, - { - Name: aws.String("vpc-id"), - Values: aws.StringSlice([]string{"vpc-bar"}), - }, + filter.EC2.SubnetStates(ec2.SubnetStatePending, ec2.SubnetStateAvailable), { Name: aws.String("availability-zone"), Values: aws.StringSlice([]string{"us-east-1c"}), @@ -669,10 +651,208 @@ func TestCreateInstance(t *testing.T) { { VpcId: aws.String("vpc-bar"), SubnetId: aws.String("subnet-4"), - AvailabilityZone: aws.String("us-east-1a"), + AvailabilityZone: aws.String("us-east-1c"), CidrBlock: aws.String("10.0.10.0/24"), MapPublicIpOnLaunch: aws.Bool(false), }, + { + VpcId: aws.String("vpc-foo"), + SubnetId: aws.String("subnet-3"), + AvailabilityZone: aws.String("us-east-1c"), + CidrBlock: aws.String("10.0.11.0/24"), + }, + }, + }, nil) + m. + RunInstancesWithContext(context.TODO(), &ec2.RunInstancesInput{ + ImageId: aws.String("abc"), + InstanceType: aws.String("m5.2xlarge"), + KeyName: aws.String("default"), + SecurityGroupIds: aws.StringSlice([]string{"2", "3"}), + SubnetId: aws.String("subnet-3"), + TagSpecifications: []*ec2.TagSpecification{ + { + ResourceType: aws.String("instance"), + Tags: []*ec2.Tag{ + { + Key: aws.String("MachineName"), + Value: aws.String("/"), + }, + { + Key: aws.String("Name"), + Value: aws.String("aws-test1"), + }, + { + Key: aws.String("kubernetes.io/cluster/test1"), + Value: aws.String("owned"), + }, + { + Key: aws.String("sigs.k8s.io/cluster-api-provider-aws/cluster/test1"), + Value: aws.String("owned"), + }, + { + Key: aws.String("sigs.k8s.io/cluster-api-provider-aws/role"), + Value: aws.String("node"), + }, + }, + }, + }, + UserData: aws.String(base64.StdEncoding.EncodeToString(userDataCompressed)), + MaxCount: aws.Int64(1), + MinCount: aws.Int64(1), + }).Return(&ec2.Reservation{ + Instances: []*ec2.Instance{ + { + State: &ec2.InstanceState{ + Name: aws.String(ec2.InstanceStateNamePending), + }, + IamInstanceProfile: &ec2.IamInstanceProfile{ + Arn: aws.String("arn:aws:iam::123456789012:instance-profile/foo"), + }, + InstanceId: aws.String("two"), + InstanceType: aws.String("m5.large"), + SubnetId: aws.String("subnet-3"), + ImageId: aws.String("ami-1"), + RootDeviceName: aws.String("device-1"), + BlockDeviceMappings: []*ec2.InstanceBlockDeviceMapping{ + { + DeviceName: aws.String("device-1"), + Ebs: &ec2.EbsInstanceBlockDevice{ + VolumeId: aws.String("volume-1"), + }, + }, + }, + Placement: &ec2.Placement{ + AvailabilityZone: &az, + }, + }, + }, + }, nil) + m. + DescribeNetworkInterfacesWithContext(context.TODO(), gomock.Any()). + Return(&ec2.DescribeNetworkInterfacesOutput{ + NetworkInterfaces: []*ec2.NetworkInterface{}, + NextToken: nil, + }, nil) + }, + check: func(instance *infrav1.Instance, err error) { + if err != nil { + t.Fatalf("did not expect error: %v", err) + } + + if instance.SubnetID != "subnet-3" { + t.Fatalf("expected subnet-3 from availability zone us-east-1c, got %q", instance.SubnetID) + } + }, + }, + { + name: "with a subnet outside the cluster vpc", + machine: &clusterv1.Machine{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{"set": "node"}, + }, + Spec: clusterv1.MachineSpec{ + Bootstrap: clusterv1.Bootstrap{ + DataSecretName: aws.String("bootstrap-data"), + }, + FailureDomain: aws.String("us-east-1c"), + }, + }, + machineConfig: &infrav1.AWSMachineSpec{ + AMI: infrav1.AMIReference{ + ID: aws.String("abc"), + }, + InstanceType: "m5.2xlarge", + Subnet: &infrav1.AWSResourceReference{ + Filters: []infrav1.Filter{ + { + Name: "vpc-id", + Values: []string{"vpc-bar"}, + }, + { + Name: "availability-zone", + Values: []string{"us-east-1c"}, + }, + }, + }, + SecurityGroupOverrides: map[infrav1.SecurityGroupRole]string{ + infrav1.SecurityGroupNode: "4", + }, + UncompressedUserData: &isUncompressedFalse, + }, + awsCluster: &infrav1.AWSCluster{ + ObjectMeta: metav1.ObjectMeta{Name: "test"}, + Spec: infrav1.AWSClusterSpec{ + NetworkSpec: infrav1.NetworkSpec{ + VPC: infrav1.VPCSpec{ + ID: "vpc-foo", + }, + Subnets: infrav1.Subnets{ + infrav1.SubnetSpec{ + ID: "subnet-1", + AvailabilityZone: "us-east-1a", + IsPublic: false, + }, + infrav1.SubnetSpec{ + ID: "subnet-2", + AvailabilityZone: "us-east-1b", + IsPublic: false, + }, + infrav1.SubnetSpec{ + ID: "subnet-3", + AvailabilityZone: "us-east-1c", + IsPublic: false, + }, + }, + }, + }, + Status: infrav1.AWSClusterStatus{ + Network: infrav1.NetworkStatus{ + SecurityGroups: map[infrav1.SecurityGroupRole]infrav1.SecurityGroup{ + infrav1.SecurityGroupControlPlane: { + ID: "1", + }, + infrav1.SecurityGroupNode: { + ID: "2", + }, + infrav1.SecurityGroupLB: { + ID: "3", + }, + }, + APIServerELB: infrav1.LoadBalancer{ + DNSName: "test-apiserver.us-east-1.aws", + }, + }, + }, + }, + expect: func(m *mocks.MockEC2APIMockRecorder) { + m. + DescribeInstanceTypesWithContext(context.TODO(), gomock.Eq(&ec2.DescribeInstanceTypesInput{ + InstanceTypes: []*string{ + aws.String("m5.2xlarge"), + }, + })). + Return(&ec2.DescribeInstanceTypesOutput{ + InstanceTypes: []*ec2.InstanceTypeInfo{ + { + ProcessorInfo: &ec2.ProcessorInfo{ + SupportedArchitectures: []*string{ + aws.String("x86_64"), + }, + }, + }, + }, + }, nil) + m.DescribeSubnetsWithContext(context.TODO(), gomock.Eq(&ec2.DescribeSubnetsInput{ + Filters: []*ec2.Filter{ + filter.EC2.SubnetStates(ec2.SubnetStatePending, ec2.SubnetStateAvailable), + filter.EC2.VPC("vpc-bar"), + { + Name: aws.String("availability-zone"), + Values: aws.StringSlice([]string{"us-east-1c"}), + }, + }})).Return(&ec2.DescribeSubnetsOutput{ + Subnets: []*ec2.Subnet{ { VpcId: aws.String("vpc-bar"), SubnetId: aws.String("subnet-5"), @@ -1289,7 +1469,6 @@ func TestCreateInstance(t *testing.T) { DescribeSubnetsWithContext(context.TODO(), &ec2.DescribeSubnetsInput{ Filters: []*ec2.Filter{ filter.EC2.SubnetStates(ec2.SubnetStatePending, ec2.SubnetStateAvailable), - filter.EC2.VPC("vpc-id"), {Name: aws.String("tag:some-tag"), Values: aws.StringSlice([]string{"some-value"})}, }, }). @@ -1399,7 +1578,6 @@ func TestCreateInstance(t *testing.T) { DescribeSubnetsWithContext(context.TODO(), &ec2.DescribeSubnetsInput{ Filters: []*ec2.Filter{ filter.EC2.SubnetStates(ec2.SubnetStatePending, ec2.SubnetStateAvailable), - filter.EC2.VPC("vpc-id"), {Name: aws.String("subnet-id"), Values: aws.StringSlice([]string{"matching-subnet"})}, }, }). @@ -1543,7 +1721,6 @@ func TestCreateInstance(t *testing.T) { DescribeSubnetsWithContext(context.TODO(), &ec2.DescribeSubnetsInput{ Filters: []*ec2.Filter{ filter.EC2.SubnetStates(ec2.SubnetStatePending, ec2.SubnetStateAvailable), - filter.EC2.VPC("vpc-id"), {Name: aws.String("subnet-id"), Values: aws.StringSlice([]string{"non-matching-subnet"})}, }, }). @@ -1666,7 +1843,6 @@ func TestCreateInstance(t *testing.T) { DescribeSubnetsWithContext(context.TODO(), &ec2.DescribeSubnetsInput{ Filters: []*ec2.Filter{ filter.EC2.SubnetStates(ec2.SubnetStatePending, ec2.SubnetStateAvailable), - filter.EC2.VPC("vpc-id"), {Name: aws.String("subnet-id"), Values: aws.StringSlice([]string{"matching-subnet"})}, }, }). @@ -1747,7 +1923,6 @@ func TestCreateInstance(t *testing.T) { DescribeSubnetsWithContext(context.TODO(), &ec2.DescribeSubnetsInput{ Filters: []*ec2.Filter{ filter.EC2.SubnetStates(ec2.SubnetStatePending, ec2.SubnetStateAvailable), - filter.EC2.VPC("vpc-id"), {Name: aws.String("subnet-id"), Values: aws.StringSlice([]string{"subnet-1"})}, }, }). @@ -1928,7 +2103,6 @@ func TestCreateInstance(t *testing.T) { DescribeSubnetsWithContext(context.TODO(), &ec2.DescribeSubnetsInput{ Filters: []*ec2.Filter{ filter.EC2.SubnetStates(ec2.SubnetStatePending, ec2.SubnetStateAvailable), - filter.EC2.VPC("vpc-id"), {Name: aws.String("subnet-id"), Values: aws.StringSlice([]string{"public-subnet-1"})}, }, }). @@ -2058,7 +2232,6 @@ func TestCreateInstance(t *testing.T) { DescribeSubnetsWithContext(context.TODO(), &ec2.DescribeSubnetsInput{ Filters: []*ec2.Filter{ filter.EC2.SubnetStates(ec2.SubnetStatePending, ec2.SubnetStateAvailable), - filter.EC2.VPC("vpc-id"), {Name: aws.String("subnet-id"), Values: aws.StringSlice([]string{"private-subnet-1"})}, }, }). @@ -2183,7 +2356,6 @@ func TestCreateInstance(t *testing.T) { DescribeSubnetsWithContext(context.TODO(), &ec2.DescribeSubnetsInput{ Filters: []*ec2.Filter{ filter.EC2.SubnetStates(ec2.SubnetStatePending, ec2.SubnetStateAvailable), - filter.EC2.VPC("vpc-id"), {Name: aws.String("tag:some-tag"), Values: aws.StringSlice([]string{"some-value"})}, }, }).