Skip to content

Commit d2d76e4

Browse files
committed
feat: adding the concept of a share network, using by the connentivity module
1 parent b61bfef commit d2d76e4

File tree

19 files changed

+517
-0
lines changed

19 files changed

+517
-0
lines changed

.github/workflows/terraform.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,27 @@ jobs:
1818
name: Module Validation
1919
with:
2020
working-directory: .
21+
22+
shared-module-validation:
23+
uses: appvia/appvia-cicd-workflows/.github/workflows/terraform-module-validation.yml@main
24+
name: Shared Module Validation
25+
with:
26+
working-directory: modules/shared
27+
28+
ram-module-validation:
29+
uses: appvia/appvia-cicd-workflows/.github/workflows/terraform-module-validation.yml@main
30+
name: RAM Module Validation
31+
with:
32+
working-directory: modules/ram
33+
34+
ram-principal-associations:
35+
uses: appvia/appvia-cicd-workflows/.github/workflows/terraform-module-validation.yml@main
36+
name: RAM Principal Associations
37+
with:
38+
working-directory: modules/ram_associations
39+
40+
ram-resource-associations:
41+
uses: appvia/appvia-cicd-workflows/.github/workflows/terraform-module-validation.yml@main
42+
name: RAM Resource Associations
43+
with:
44+
working-directory: modules/ram_resources

modules/ram/main.tf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
## Provision a RAM resource share
3+
resource "aws_ram_resource_share" "this" {
4+
name = var.name
5+
tags = var.tags
6+
allow_external_principals = var.allow_external_principals
7+
}
8+
9+
## Associate the resources to the resource share
10+
module "resource_associations" {
11+
source = "../ram_resources"
12+
for_each = { for resource in var.resources : resource.name => resource }
13+
14+
resource_arn = each.value.resource_arn
15+
resource_share_arn = aws_ram_resource_share.this.arn
16+
}
17+
18+
## Associate the principals to the resource share
19+
module "principal_associations" {
20+
source = "../ram_associations"
21+
for_each = toset(var.principals)
22+
23+
principal = each.value
24+
resource_share_arn = aws_ram_resource_share.this.arn
25+
}

modules/ram/outputs.tf

Whitespace-only changes.

modules/ram/terarform.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
terraform {
3+
required_version = ">= 1.0"
4+
5+
required_providers {
6+
aws = {
7+
source = "hashicorp/aws"
8+
version = "~> 5.0"
9+
}
10+
}
11+
}

modules/ram/variables.tf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
variable "name" {
2+
description = "Name of the resource share"
3+
type = string
4+
}
5+
6+
variable "allow_external_principals" {
7+
description = "Allow external principals to associate with the resource share."
8+
type = bool
9+
default = false
10+
}
11+
12+
variable "principals" {
13+
description = "List of principals to associate with the resource share."
14+
type = list(string)
15+
default = []
16+
}
17+
18+
variable "resources" {
19+
description = "Schema list of resources to associate to the resource share"
20+
type = list(object({
21+
name = string
22+
resource_arn = string
23+
}))
24+
default = []
25+
}
26+
27+
variable "tags" {
28+
description = "Map of tags to assign to the resource share"
29+
type = map(string)
30+
}

modules/ram_associations/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
resource "aws_ram_principal_association" "this" {
3+
principal = var.principal
4+
resource_share_arn = var.resource_share_arn
5+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "principal_association" {
2+
description = "Object with the AWS RAM principal association resource"
3+
value = aws_ram_principal_association.this
4+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
terraform {
3+
required_version = ">= 1.0"
4+
5+
required_providers {
6+
aws = {
7+
source = "hashicorp/aws"
8+
version = "~> 5.0"
9+
}
10+
}
11+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
variable "principal" {
2+
description = "The principal to associate with the resource share."
3+
type = string
4+
}
5+
6+
variable "resource_share_arn" {
7+
description = "ARN of the resource share"
8+
type = string
9+
}

modules/ram_resources/main.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Associate the principal to the resource share
2+
resource "aws_ram_resource_association" "this" {
3+
resource_arn = var.resource_arn
4+
resource_share_arn = var.resource_share_arn
5+
}

0 commit comments

Comments
 (0)