Skip to content

Commit

Permalink
Add column maintenance_options, placement_*, spot_instance_request_id…
Browse files Browse the repository at this point in the history
… and licenses columns to aws_ec2_instance table closes #1708 (#1709)
  • Loading branch information
ParthaI authored Apr 20, 2023
1 parent 861b9df commit 6deca3f
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 1 deletion.
46 changes: 45 additions & 1 deletion aws/table_aws_ec2_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,18 +201,48 @@ func tableAwsEc2Instance(_ context.Context) *plugin.Table {
Description: "The Amazon Resource Name (ARN) of the Outpost, if applicable.",
Type: proto.ColumnType_STRING,
},
{
Name: "placement_affinity",
Description: "The affinity setting for the instance on the Dedicated Host.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("Placement.Affinity"),
},
{
Name: "placement_availability_zone",
Description: "The Availability Zone of the instance.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("Placement.AvailabilityZone"),
},
{
Name: "placement_group_id",
Description: "The ID of the placement group that the instance is in.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("Placement.GroupId"),
},
{
Name: "placement_group_name",
Description: "The name of the placement group the instance is in.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("Placement.GroupName"),
},
{
Name: "placement_host_id",
Description: "The ID of the Dedicated Host on which the instance resides.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("Placement.HostId"),
},
{
Name: "placement_host_resource_group_arn",
Description: "The ARN of the host resource group in which to launch the instances.",
Type: proto.ColumnType_STRING,
Transform: transform.FromField("Placement.HostResourceGroupArn"),
},
{
Name: "placement_partition_number",
Description: "The ARN of the host resource group in which to launch the instances.",
Type: proto.ColumnType_INT,
Transform: transform.FromField("Placement.PartitionNumber"),
},
{
Name: "placement_tenancy",
Description: "The tenancy of the instance (if the instance is running in a VPC). An instance with a tenancy of dedicated runs on single-tenant hardware.",
Expand Down Expand Up @@ -271,6 +301,11 @@ func tableAwsEc2Instance(_ context.Context) *plugin.Table {
Description: "Specifies whether to enable an instance launched in a VPC to perform NAT. This controls whether source/destination checking is enabled on the instance.",
Type: proto.ColumnType_BOOL,
},
{
Name: "spot_instance_request_id",
Description: "If the request is a Spot Instance request, the ID of the request.",
Type: proto.ColumnType_STRING,
},
{
Name: "sriov_net_support",
Description: "Indicates whether enhanced networking with the Intel 82599 Virtual Function interface is enabled.",
Expand Down Expand Up @@ -364,6 +399,16 @@ func tableAwsEc2Instance(_ context.Context) *plugin.Table {
Type: proto.ColumnType_JSON,
Transform: transform.FromValue(),
},
{
Name: "licenses",
Description: "The license configurations for the instance.",
Type: proto.ColumnType_JSON,
},
{
Name: "maintenance_options",
Description: "The metadata options for the instance.",
Type: proto.ColumnType_JSON,
},
{
Name: "metadata_options",
Description: "The metadata options for the instance.",
Expand Down Expand Up @@ -688,7 +733,6 @@ func getInstanceUserData(ctx context.Context, d *plugin.QueryData, h *plugin.Hyd
return instanceData, nil
}


func getEc2LaunchTemplateData(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {
// Get the details of load balancer
instance := h.Item.(types.Instance)
Expand Down
43 changes: 43 additions & 0 deletions docs/tables/aws_ec2_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,49 @@ where
not tags :: JSONB ? 'application';
```

### Get maintenance options for each instance

```sql
select
instance_id,
instance_state,
launch_time,
maintenance_options ->> 'AutoRecovery' as auto_recovery
from
aws_ec2_instance;
```

### Get license details for each instance

```sql
select
instance_id,
instance_type,
instance_state,
l ->> 'LicenseConfigurationArn' as license_configuration_arn
from
aws_ec2_instance,
jsonb_array_elements(licenses) as l;
```

### Get placement group details for each instance

```sql
select
instance_id,
instance_state,
placement_affinity,
placement_group_id,
placement_group_name,
placement_availability_zone,
placement_host_id,
placement_host_resource_group_arn,
placement_partition_number,
placement_tenancy
from
aws_ec2_instance;
```

### List of EC2 instances provisioned with undesired(for example t2.large and m3.medium is desired) instance type(s).

```sql
Expand Down

0 comments on commit 6deca3f

Please sign in to comment.