From dd70a3f615013bd9e427a27e075c37326c530e5e Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Sun, 10 Dec 2023 22:27:25 -0800 Subject: [PATCH] Improve security group defaults + ptr cleanup (#2787) Improve the defaults and cleanup some string conversions. Signed-off-by: Tim Smith --- providers/aws/resources/aws.lr | 2 +- providers/aws/resources/aws_ec2.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/providers/aws/resources/aws.lr b/providers/aws/resources/aws.lr index 9c04b4ae93..b24cdf0321 100644 --- a/providers/aws/resources/aws.lr +++ b/providers/aws/resources/aws.lr @@ -1890,7 +1890,7 @@ private aws.ec2.instance.device { } // Amazon EC2 security group -private aws.ec2.securitygroup @defaults("arn") { +private aws.ec2.securitygroup @defaults("id name region vpc.id") { // Security group ARN arn string // Security group ID diff --git a/providers/aws/resources/aws_ec2.go b/providers/aws/resources/aws_ec2.go index 3f20e0dae2..264d5a8a2d 100644 --- a/providers/aws/resources/aws_ec2.go +++ b/providers/aws/resources/aws_ec2.go @@ -269,7 +269,7 @@ func (a *mqlAwsEc2) getSecurityGroups(conn *connection.AwsConnection) []*jobpool "id": llx.StringData(convert.ToString(group.GroupId) + "-" + strconv.Itoa(p)), "fromPort": llx.IntData(convert.ToInt64From32(permission.FromPort)), "toPort": llx.IntData(convert.ToInt64From32(permission.ToPort)), - "ipProtocol": llx.StringData(convert.ToString(permission.IpProtocol)), + "ipProtocol": llx.StringDataPtr(permission.IpProtocol), "ipRanges": llx.ArrayData(ipRanges, types.Any), "ipv6Ranges": llx.ArrayData(ipv6Ranges, types.Any), }) @@ -304,7 +304,7 @@ func (a *mqlAwsEc2) getSecurityGroups(conn *connection.AwsConnection) []*jobpool "id": llx.StringData(convert.ToString(group.GroupId) + "-" + strconv.Itoa(p) + "-egress"), "fromPort": llx.IntData(convert.ToInt64From32(permission.FromPort)), "toPort": llx.IntData(convert.ToInt64From32(permission.ToPort)), - "ipProtocol": llx.StringData(convert.ToString(permission.IpProtocol)), + "ipProtocol": llx.StringDataPtr(permission.IpProtocol), "ipRanges": llx.ArrayData(ipRanges, types.Any), "ipv6Ranges": llx.ArrayData(ipv6Ranges, types.Any), }) @@ -317,9 +317,9 @@ func (a *mqlAwsEc2) getSecurityGroups(conn *connection.AwsConnection) []*jobpool args := map[string]*llx.RawData{ "arn": llx.StringData(fmt.Sprintf(securityGroupArnPattern, regionVal, conn.AccountId(), convert.ToString(group.GroupId))), - "id": llx.StringData(convert.ToString(group.GroupId)), - "name": llx.StringData(convert.ToString(group.GroupName)), - "description": llx.StringData(convert.ToString(group.Description)), + "id": llx.StringDataPtr(group.GroupId), + "name": llx.StringDataPtr(group.GroupName), + "description": llx.StringDataPtr(group.Description), "tags": llx.MapData(Ec2TagsToMap(group.Tags), types.String), "ipPermissions": llx.ArrayData(mqlIpPermissions, types.Resource("aws.ec2.securitygroup.ippermission")), "ipPermissionsEgress": llx.ArrayData(mqlIpPermissionsEgress, types.Resource("aws.ec2.securitygroup.ippermission")),