Skip to content

Commit 2ee69d3

Browse files
authored
feat: add aws_ec2_fleet table (#2689)
1 parent 54d8195 commit 2ee69d3

9 files changed

Lines changed: 777 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"fleet_id": "{{ output.resource_id.value }}",
4+
"arn": "{{ output.resource_aka.value }}",
5+
"type": "maintain",
6+
"excess_capacity_termination_policy": "termination",
7+
"replace_unhealthy_instances": false,
8+
"name": "{{ resourceName }}"
9+
}
10+
]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
select fleet_id, arn, type, excess_capacity_termination_policy, replace_unhealthy_instances, tags ->> 'Name' as name
2+
from aws.aws_ec2_fleet
3+
where fleet_id = '{{ output.resource_id.value }}'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"fleet_id": "{{ output.resource_id.value }}",
4+
"arn": "{{ output.resource_aka.value }}",
5+
"type": "maintain",
6+
"excess_capacity_termination_policy": "termination",
7+
"replace_unhealthy_instances": false,
8+
"name": "{{ resourceName }}"
9+
}
10+
]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
select fleet_id, arn, type, excess_capacity_termination_policy, replace_unhealthy_instances, tags ->> 'Name' as name
2+
from aws.aws_ec2_fleet
3+
where tags ->> 'Name' = '{{ resourceName }}'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"resource_name": "turbot-test-20200125-create-update-fleet"
3+
}
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
variable "resource_name" {
2+
type = string
3+
default = "turbot-test-20200125-create-update-fleet"
4+
description = "Name of the resource used throughout the test."
5+
}
6+
7+
variable "aws_profile" {
8+
type = string
9+
default = "default"
10+
description = "AWS credentials profile used for the test. Default is to use the default profile."
11+
}
12+
13+
variable "aws_region" {
14+
type = string
15+
default = "us-east-1"
16+
description = "AWS region used for the test. Does not work with default region in config, so must be defined here."
17+
}
18+
19+
variable "aws_region_alternate" {
20+
type = string
21+
default = "us-east-2"
22+
description = "Alternate AWS region used for tests that require two regions (e.g. DynamoDB global tables)."
23+
}
24+
25+
provider "aws" {
26+
profile = var.aws_profile
27+
region = var.aws_region
28+
}
29+
30+
provider "aws" {
31+
alias = "alternate"
32+
profile = var.aws_profile
33+
region = var.aws_region_alternate
34+
}
35+
36+
data "aws_partition" "current" {}
37+
data "aws_caller_identity" "current" {}
38+
data "aws_region" "primary" {}
39+
data "aws_region" "alternate" {
40+
provider = aws.alternate
41+
}
42+
43+
data "null_data_source" "resource" {
44+
inputs = {
45+
scope = "arn:${data.aws_partition.current.partition}:::${data.aws_caller_identity.current.account_id}"
46+
}
47+
}
48+
49+
data "aws_ami" "ubuntu" {
50+
most_recent = true
51+
filter {
52+
name = "name"
53+
values = ["ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*"]
54+
}
55+
filter {
56+
name = "virtualization-type"
57+
values = ["hvm"]
58+
}
59+
owners = ["099720109477"]
60+
}
61+
62+
resource "aws_launch_template" "named_test_resource" {
63+
name = var.resource_name
64+
image_id = data.aws_ami.ubuntu.id
65+
instance_type = "t3.micro"
66+
67+
tags = {
68+
Name = var.resource_name
69+
}
70+
}
71+
72+
resource "aws_ec2_fleet" "named_test_resource" {
73+
launch_template_config {
74+
launch_template_specification {
75+
launch_template_id = aws_launch_template.named_test_resource.id
76+
version = aws_launch_template.named_test_resource.latest_version
77+
}
78+
}
79+
80+
target_capacity_specification {
81+
default_target_capacity_type = "spot"
82+
total_target_capacity = 1
83+
}
84+
85+
type = "maintain"
86+
87+
excess_capacity_termination_policy = "termination"
88+
89+
replace_unhealthy_instances = false
90+
91+
tags = {
92+
Name = var.resource_name
93+
}
94+
}
95+
96+
output "resource_aka" {
97+
value = aws_ec2_fleet.named_test_resource.arn
98+
}
99+
100+
output "resource_id" {
101+
value = aws_ec2_fleet.named_test_resource.id
102+
}
103+
104+
output "resource_name" {
105+
value = var.resource_name
106+
}
107+
108+
output "aws_partition" {
109+
value = data.aws_partition.current.partition
110+
}
111+
112+
output "account_id" {
113+
value = data.aws_caller_identity.current.account_id
114+
}
115+
116+
output "launch_template_id" {
117+
value = aws_launch_template.named_test_resource.id
118+
}

aws/plugin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ func Plugin(ctx context.Context) *plugin.Plugin {
396396
"aws_ec2_capacity_reservation": tableAwsEc2CapacityReservation(ctx),
397397
"aws_ec2_classic_load_balancer": tableAwsEc2ClassicLoadBalancer(ctx),
398398
"aws_ec2_client_vpn_endpoint": tableAwsEC2ClientVPNEndpoint(ctx),
399+
"aws_ec2_fleet": tableAwsEc2Fleet(ctx),
399400
"aws_ec2_gateway_load_balancer": tableAwsEc2GatewayLoadBalancer(ctx),
400401
"aws_ec2_instance_availability": tableAwsInstanceAvailability(ctx),
401402
"aws_ec2_instance_metric_cpu_utilization_daily": tableAwsEc2InstanceMetricCpuUtilizationDaily(ctx),

0 commit comments

Comments
 (0)