Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Commit 847cb92

Browse files
npalmnavdeepg2021
andauthored
chore: Add resource groups for examples (#2514)
* chore: Add resource groups for examples * chore: Add resource groups for examples * replace var by local for aws region * review fixes * fix: reverted. * fix: updated tags for all examples. Co-authored-by: navdeepg2021 <[email protected]>
1 parent 120940e commit 847cb92

20 files changed

+119
-105
lines changed

Diff for: examples/base/main.tf

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
resource "aws_resourcegroups_group" "resourcegroups_group" {
2+
name = "${var.prefix}-group"
3+
resource_query {
4+
query = templatefile("${path.module}/templates/resource-group.json", {
5+
example = var.prefix
6+
})
7+
}
8+
}

Diff for: examples/base/outputs.tf

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
output "vpc" {
2+
value = module.vpc
3+
}

Diff for: examples/base/templates/resource-group.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"ResourceTypeFilters": ["AWS::AllSupported"],
3+
"TagFilters": [
4+
{
5+
"Key": "Example",
6+
"Values": ["${example}"]
7+
}
8+
]
9+
}

Diff for: examples/base/variables.tf

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
variable "prefix" {
2+
description = "Prefix used for resource naming."
3+
type = string
4+
}
5+
6+
variable "aws_region" {
7+
description = "AWS region to create the VPC, assuming zones `a` and `b` exists."
8+
type = string
9+
}

Diff for: examples/base/vpc.tf

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module "vpc" {
2+
source = "terraform-aws-modules/vpc/aws"
3+
version = "3.16.0"
4+
5+
name = "${var.prefix}-vpc"
6+
cidr = "10.0.0.0/16"
7+
8+
azs = ["${var.aws_region}a", "${var.aws_region}b"]
9+
private_subnets = ["10.0.1.0/24", "10.0.2.0/24"]
10+
public_subnets = ["10.0.101.0/24", "10.0.102.0/24"]
11+
12+
enable_dns_hostnames = true
13+
enable_nat_gateway = true
14+
map_public_ip_on_launch = false
15+
single_nat_gateway = true
16+
}

Diff for: examples/default/main.tf

+7-5
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ resource "random_id" "random" {
77
byte_length = 20
88
}
99

10+
module "base" {
11+
source = "../base"
1012

11-
################################################################################
12-
### Hybrid account
13-
################################################################################
13+
prefix = local.environment
14+
aws_region = local.aws_region
15+
}
1416

1517
module "runners" {
1618
source = "../../"
1719
create_service_linked_role_spot = true
1820
aws_region = local.aws_region
19-
vpc_id = module.vpc.vpc_id
20-
subnet_ids = module.vpc.private_subnets
21+
vpc_id = module.base.vpc.vpc_id
22+
subnet_ids = module.base.vpc.private_subnets
2123

2224
prefix = local.environment
2325
tags = {

Diff for: examples/default/providers.tf

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
provider "aws" {
22
region = local.aws_region
3+
4+
default_tags {
5+
tags = {
6+
Example = local.environment
7+
}
8+
}
39
}

Diff for: examples/default/vpc.tf

-21
This file was deleted.

Diff for: examples/ephemeral/main.tf

+10-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,20 @@ resource "random_id" "random" {
99

1010
data "aws_caller_identity" "current" {}
1111

12+
13+
module "base" {
14+
source = "../base"
15+
16+
prefix = local.environment
17+
aws_region = local.aws_region
18+
}
19+
1220
module "runners" {
1321
source = "../../"
1422
create_service_linked_role_spot = true
1523
aws_region = local.aws_region
16-
vpc_id = module.vpc.vpc_id
17-
subnet_ids = module.vpc.private_subnets
24+
vpc_id = module.base.vpc.vpc_id
25+
subnet_ids = module.base.vpc.private_subnets
1826

1927
prefix = local.environment
2028
tags = {

Diff for: examples/ephemeral/providers.tf

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
provider "aws" {
22
region = local.aws_region
3+
default_tags {
4+
tags = {
5+
Example = local.environment
6+
}
7+
}
38
}

Diff for: examples/ephemeral/vpc.tf

-21
This file was deleted.

Diff for: examples/prebuilt/main.tf

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
locals {
22
environment = "prebuilt"
3+
aws_region = "eu-west-1"
34
}
45

56
resource "random_id" "random" {
@@ -8,12 +9,19 @@ resource "random_id" "random" {
89

910
data "aws_caller_identity" "current" {}
1011

12+
module "base" {
13+
source = "../base"
14+
15+
prefix = local.environment
16+
aws_region = local.aws_region
17+
}
18+
1119
module "runners" {
1220
source = "../../"
1321
create_service_linked_role_spot = true
14-
aws_region = var.aws_region
15-
vpc_id = module.vpc.vpc_id
16-
subnet_ids = module.vpc.private_subnets
22+
aws_region = local.aws_region
23+
vpc_id = module.base.vpc.vpc_id
24+
subnet_ids = module.base.vpc.private_subnets
1725

1826
prefix = local.environment
1927
enable_organization_runners = false

Diff for: examples/prebuilt/providers.tf

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
provider "aws" {
2-
region = var.aws_region
2+
region = local.aws_region
3+
default_tags {
4+
tags = {
5+
Example = local.environment
6+
}
7+
}
38
}

Diff for: examples/prebuilt/variables.tf

-5
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,3 @@ variable "ami_name_filter" {
1212
type = string
1313
default = "github-runner-amzn2-x86_64-*"
1414
}
15-
16-
variable "aws_region" {
17-
type = string
18-
default = "eu-west-1"
19-
}

Diff for: examples/prebuilt/vpc.tf

-21
This file was deleted.

Diff for: examples/ubuntu/main.tf

+10-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,20 @@ resource "random_id" "random" {
99

1010
data "aws_caller_identity" "current" {}
1111

12+
13+
module "base" {
14+
source = "../base"
15+
16+
prefix = local.environment
17+
aws_region = local.aws_region
18+
}
19+
1220
module "runners" {
1321
source = "../../"
1422

1523
aws_region = local.aws_region
16-
vpc_id = module.vpc.vpc_id
17-
subnet_ids = module.vpc.private_subnets
24+
vpc_id = module.base.vpc.vpc_id
25+
subnet_ids = module.base.vpc.private_subnets
1826

1927
prefix = local.environment
2028
tags = {

Diff for: examples/ubuntu/providers.tf

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
provider "aws" {
22
region = local.aws_region
3-
3+
default_tags {
4+
tags = {
5+
Example = local.environment
6+
}
7+
}
48
// If you use roles with specific permissions please add your role
59
// assume_role {
610
// role_arn = "arn:aws:iam::123456789012:role/MyAdminRole"

Diff for: examples/windows/main.tf

+9-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@ resource "random_id" "random" {
77
byte_length = 20
88
}
99

10+
module "base" {
11+
source = "../base"
12+
13+
prefix = local.environment
14+
aws_region = local.aws_region
15+
}
16+
1017
module "runners" {
1118
source = "../../"
1219

1320
aws_region = local.aws_region
14-
vpc_id = module.vpc.vpc_id
15-
subnet_ids = module.vpc.private_subnets
21+
vpc_id = module.base.vpc.vpc_id
22+
subnet_ids = module.base.vpc.private_subnets
1623
prefix = local.environment
1724

1825
github_app = {

Diff for: examples/windows/providers.tf

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
provider "aws" {
22
region = local.aws_region
3+
default_tags {
4+
tags = {
5+
Example = local.environment
6+
}
7+
}
38
}

Diff for: examples/windows/vpc.tf

-21
This file was deleted.

0 commit comments

Comments
 (0)