Skip to content

Commit

Permalink
Remove deprecated 'securityGroupId' property from createEC2InstanceInput
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVulaj committed Jul 11, 2024
1 parent 705bbe5 commit 46bbee7
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 15 deletions.
5 changes: 0 additions & 5 deletions cmd/egress/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ type egressConfig struct {
vpcSubnetID string
cloudImageID string
instanceType string
securityGroupId string // Deprecated: prefer securityGroupIDs
securityGroupIDs []string
cloudTags map[string]string
debug bool
Expand Down Expand Up @@ -142,7 +141,6 @@ are set correctly before execution.
//Setup AWS Specific Configs
vei.AWS = verifier.AwsEgressConfig{
KmsKeyID: config.kmsKeyID,
SecurityGroupId: config.securityGroupId,
SecurityGroupIDs: config.securityGroupIDs,
}

Expand Down Expand Up @@ -239,7 +237,6 @@ are set correctly before execution.
validateEgressCmd.Flags().StringVar(&config.vpcSubnetID, "subnet-id", "", "source subnet ID")
validateEgressCmd.Flags().StringVar(&config.cloudImageID, "image-id", "", "(optional) cloud image for the compute instance")
validateEgressCmd.Flags().StringVar(&config.instanceType, "instance-type", "t3.micro", "(optional) compute instance type")
validateEgressCmd.Flags().StringVar(&config.securityGroupId, "security-group-id", "", "(deprecated in favor of --security-group-ids)")
validateEgressCmd.Flags().StringSliceVar(&config.securityGroupIDs, "security-group-ids", []string{}, "(optional) comma-separated list of sec. group IDs to attach to the created EC2 instance. If absent, one will be created")
validateEgressCmd.Flags().StringVar(&config.region, "region", "", fmt.Sprintf("(optional) compute instance region. If absent, environment var %[1]v = %[2]v and %[3]v = %[4]v will be used", awsRegionEnvVarStr, awsRegionDefault, gcpRegionEnvVarStr, gcpRegionDefault))
validateEgressCmd.Flags().StringToStringVar(&config.cloudTags, "cloud-tags", map[string]string{}, "(optional) comma-seperated list of tags to assign to cloud resources e.g. --cloud-tags key1=value1,key2=value2")
Expand All @@ -261,7 +258,5 @@ are set correctly before execution.
validateEgressCmd.PrintErr(err)
}

//Mark securityGroupId and securityGroupsIDs flags as mutually exclusive (one or the other should be passed, not both).
validateEgressCmd.MarkFlagsMutuallyExclusive("security-group-id", "security-group-ids")
return validateEgressCmd
}
7 changes: 0 additions & 7 deletions pkg/verifier/aws/aws_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ type createEC2InstanceInput struct {
SubnetID string
userdata string
KmsKeyID string
securityGroupId string // Deprecated: prefer securityGroupIDs
securityGroupIDs []string
tempSecurityGroupID string
instanceCount int32
Expand All @@ -181,12 +180,6 @@ func (a *AwsVerifier) createEC2Instance(input createEC2InstanceInput) (string, e
SubnetId: awsTools.String(input.SubnetID),
}

// An empty string does not default to the default security group, and returns this error:
// error performing ec2:RunInstances: Value () for parameter groupId is invalid. The value cannot be empty
if input.securityGroupId != "" {
eniSpecification.Groups = append(eniSpecification.Groups, input.securityGroupId)
}

if len(input.securityGroupIDs) > 0 {
eniSpecification.Groups = input.securityGroupIDs
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/verifier/aws/entry_point.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (a *AwsVerifier) ValidateEgress(vei verifier.ValidateEgressInput) *output.O
}

// If security group not given, create a temporary one
if vei.AWS.SecurityGroupId == "" && len(vei.AWS.SecurityGroupIDs) == 0 || vei.ForceTempSecurityGroup {
if len(vei.AWS.SecurityGroupIDs) == 0 || vei.ForceTempSecurityGroup {

createSecurityGroupOutput, err := a.CreateSecurityGroup(vei.Ctx, vei.Tags, "osd-network-verifier", vpcId)
if err != nil {
Expand Down Expand Up @@ -215,7 +215,6 @@ func (a *AwsVerifier) ValidateEgress(vei verifier.ValidateEgressInput) *output.O
ctx: vei.Ctx,
instanceType: vei.InstanceType,
tags: vei.Tags,
securityGroupId: vei.AWS.SecurityGroupId,
securityGroupIDs: vei.AWS.SecurityGroupIDs,
tempSecurityGroupID: vei.AWS.TempSecurityGroup,
keyPair: vei.ImportKeyPair,
Expand Down
1 change: 0 additions & 1 deletion pkg/verifier/package_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ type ValidateEgressInput struct {
}
type AwsEgressConfig struct {
KmsKeyID string
SecurityGroupId string // Deprecated: prefer securityGroupIDs
SecurityGroupIDs []string
TempSecurityGroup string
}
Expand Down

0 comments on commit 46bbee7

Please sign in to comment.