Skip to content

Commit cabba9a

Browse files
authored
Add lattice-shared-service-network and lattice-shared-service (#15)
1 parent d49fed3 commit cabba9a

File tree

19 files changed

+645
-1
lines changed

19 files changed

+645
-1
lines changed

.github/labeler.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@
2929
":floppy_disk: lattice-service":
3030
- modules/lattice-service/**/*
3131

32+
":floppy_disk: lattice-shared-service-network":
33+
- modules/lattice-shared-service-network/**/*
34+
35+
":floppy_disk: lattice-shared-service":
36+
- modules/lattice-shared-service/**/*
37+
3238
":floppy_disk: reachability-analyzer-path":
3339
- modules/reachability-analyzer-path/**/*
3440

.github/labels.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@
7070
- color: "fbca04"
7171
description: "This issue or pull request is related to lattice-service module."
7272
name: ":floppy_disk: lattice-service"
73+
- color: "fbca04"
74+
description: "This issue or pull request is related to lattice-shared-service-network module."
75+
name: ":floppy_disk: lattice-shared-service-network"
76+
- color: "fbca04"
77+
description: "This issue or pull request is related to lattice-shared-service module."
78+
name: ":floppy_disk: lattice-shared-service"
7379
- color: "fbca04"
7480
description: "This issue or pull request is related to reachability-analyzer-path module."
7581
name: ":floppy_disk: reachability-analyzer-path"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Terraform module which creates VPC Connectivity related resources (VPC Peering,
1616
- [lattice-service-listener](./modules/lattice-service-listener)
1717
- [lattice-service-network](./modules/lattice-service-network)
1818
- [lattice-service](./modules/lattice-service)
19+
- [lattice-shared-service-network](./modules/lattice-shared-service-network)
20+
- [lattice-shared-service](./modules/lattice-shared-service)
1921
- [reachability-analyzer-path](./modules/reachability-analyzer-path)
2022
- [vpc-endpoint-service](./modules/vpc-endpoint-service)
2123
- [vpc-gateway-endpoint](./modules/vpc-gateway-endpoint)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.0
1+
0.2.2

modules/lattice-service-network/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ This module creates following resources.
4242
| [aws_vpclattice_service_network.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpclattice_service_network) | resource |
4343
| [aws_vpclattice_service_network_service_association.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpclattice_service_network_service_association) | resource |
4444
| [aws_vpclattice_service_network_vpc_association.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpclattice_service_network_vpc_association) | resource |
45+
| [aws_vpclattice_service_network.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpclattice_service_network) | data source |
4546

4647
## Inputs
4748

@@ -70,11 +71,13 @@ This module creates following resources.
7071
|------|-------------|
7172
| <a name="output_arn"></a> [arn](#output\_arn) | The ARN of the service network. |
7273
| <a name="output_auth_type"></a> [auth\_type](#output\_auth\_type) | The type of authentication and authorization that manages client access to the service network. |
74+
| <a name="output_created_at"></a> [created\_at](#output\_created\_at) | Date and time that the service network was created, specified in ISO-8601 format. |
7375
| <a name="output_description"></a> [description](#output\_description) | The description of the service network. |
7476
| <a name="output_id"></a> [id](#output\_id) | The ID of the service network. |
7577
| <a name="output_logging"></a> [logging](#output\_logging) | The configuration for access logs of the service network.<br> Firehose Delivery Stream, Amazon S3 Bucket.<br> `cloudwatch` - The configuration for access logs to be sent to Amazon CloudWatch Log Group.<br> `kinesis_data_firehose` - The configuration for access logs to be sent to Amazon Kinesis Data<br> Firehose Delivery Stream.<br> `s3` - The configuration for access logs to be sent to Amazon S3 BUcket. |
7678
| <a name="output_name"></a> [name](#output\_name) | The name of the service network. |
7779
| <a name="output_service_associations"></a> [service\_associations](#output\_service\_associations) | The list of the service associations with the service network.<br> `id` - The ID of the association.<br> `arn` - The ARN of the Association.<br> `status` - The operations status. Valid Values are `CREATE_IN_PROGRESS`, `ACTIVE`, `DELETE_IN_PROGRESS`, `CREATE_FAILED`, `DELETE_FAILED`.<br> `created_by` - The principal that created the association.<br><br> `service` - The ARN (Amazon Resource Name) of the service. |
7880
| <a name="output_sharing"></a> [sharing](#output\_sharing) | The configuration for sharing of the Lattice service network.<br> `status` - An indication of whether the Lattice service network is shared with other AWS accounts, or was shared with the current account by another AWS account. Sharing is configured through AWS Resource Access Manager (AWS RAM). Values are `NOT_SHARED`, `SHARED_BY_ME` or `SHARED_WITH_ME`.<br> `shares` - The list of resource shares via RAM (Resource Access Manager). |
81+
| <a name="output_updated_at"></a> [updated\_at](#output\_updated\_at) | Date and time that the service network was last updated, specified in ISO-8601 format. |
7982
| <a name="output_vpc_associations"></a> [vpc\_associations](#output\_vpc\_associations) | The list of VPC associations with the service network.<br> `id` - The ID of the association.<br> `arn` - The ARN of the Association.<br> `status` - The operations status. Valid Values are `CREATE_IN_PROGRESS`, `ACTIVE`, `DELETE_IN_PROGRESS`, `CREATE_FAILED`, `DELETE_FAILED`.<br> `created_by` - The principal that created the association.<br><br> `vpc` - The ID of the VPC.<br> `security_groups` - A list of the IDs of the security groups. |
8083
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

modules/lattice-service-network/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ resource "aws_vpclattice_service_network_vpc_association" "this" {
5959
)
6060
}
6161

62+
data "aws_vpclattice_service_network" "this" {
63+
service_network_identifier = aws_vpclattice_service_network.this.id
64+
}
65+
6266

6367
###################################################
6468
# Service Associations of Service Network

modules/lattice-service-network/outputs.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ output "logging" {
112112
}
113113
}
114114

115+
output "created_at" {
116+
description = "Date and time that the service network was created, specified in ISO-8601 format."
117+
value = data.aws_vpclattice_service_network.this.created_at
118+
}
119+
120+
output "updated_at" {
121+
description = "Date and time that the service network was last updated, specified in ISO-8601 format."
122+
value = data.aws_vpclattice_service_network.this.last_updated_at
123+
}
124+
115125
output "sharing" {
116126
description = <<EOF
117127
The configuration for sharing of the Lattice service network.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# lattice-shared-service-network
2+
3+
This module creates following resources.
4+
5+
- `aws_vpclattice_service_network_vpc_association` (optional)
6+
- `aws_vpclattice_service_network_service_association` (optional)
7+
8+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
9+
## Requirements
10+
11+
| Name | Version |
12+
|------|---------|
13+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5 |
14+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.12 |
15+
16+
## Providers
17+
18+
| Name | Version |
19+
|------|---------|
20+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.17.0 |
21+
22+
## Modules
23+
24+
| Name | Source | Version |
25+
|------|--------|---------|
26+
| <a name="module_resource_group"></a> [resource\_group](#module\_resource\_group) | tedilabs/misc/aws//modules/resource-group | ~> 0.10.0 |
27+
28+
## Resources
29+
30+
| Name | Type |
31+
|------|------|
32+
| [aws_vpclattice_service_network_service_association.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpclattice_service_network_service_association) | resource |
33+
| [aws_vpclattice_service_network_vpc_association.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpclattice_service_network_vpc_association) | resource |
34+
| [aws_vpclattice_service_network.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpclattice_service_network) | data source |
35+
36+
## Inputs
37+
38+
| Name | Description | Type | Default | Required |
39+
|------|-------------|------|---------|:--------:|
40+
| <a name="input_id"></a> [id](#input\_id) | (Required) The ID of the service network. | `string` | n/a | yes |
41+
| <a name="input_module_tags_enabled"></a> [module\_tags\_enabled](#input\_module\_tags\_enabled) | (Optional) Whether to create AWS Resource Tags for the module informations. | `bool` | `true` | no |
42+
| <a name="input_resource_group_description"></a> [resource\_group\_description](#input\_resource\_group\_description) | (Optional) The description of Resource Group. | `string` | `"Managed by Terraform."` | no |
43+
| <a name="input_resource_group_enabled"></a> [resource\_group\_enabled](#input\_resource\_group\_enabled) | (Optional) Whether to create Resource Group to find and group AWS resources which are created by this module. | `bool` | `true` | no |
44+
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | (Optional) The name of Resource Group. A Resource Group name can have a maximum of 127 characters, including letters, numbers, hyphens, dots, and underscores. The name cannot start with `AWS` or `aws`. | `string` | `""` | no |
45+
| <a name="input_service_associations"></a> [service\_associations](#input\_service\_associations) | (Optional) The configuration for the service associations with the service network. To facilitate network client access to your service, you will need to associate your service to the relevant service networks. Only service networks created in the same account, or that have been shared with you (by way of Resource Access Manager), are available for you to create associations with. Each block of `service_associations` as defined below.<br> (Required) `name` - The name of the service association.<br> (Required) `service` - The ID or ARN (Amazon Resource Name) of the service.<br> (Optional) `tags` - A map of tags to add to the service association. | <pre>list(object({<br> name = string<br> service = string<br> tags = optional(map(string), {})<br> }))</pre> | `[]` | no |
46+
| <a name="input_tags"></a> [tags](#input\_tags) | (Optional) A map of tags to add to all resources. | `map(string)` | `{}` | no |
47+
| <a name="input_vpc_associations"></a> [vpc\_associations](#input\_vpc\_associations) | (Optional) The configuration for VPC associations with the service network. It enables all the resources within that VPC to be clients and communicate with other services in the service network. Each block of `vpc_associations` as defined below.<br> (Required) `vpc` - The ID of the VPC.<br> (Optional) `security_groups` - A list of the IDs of the security groups.<br> (Optional) `tags` - A map of tags to add to the vpc association. | <pre>list(object({<br> vpc = string<br> security_groups = optional(set(string), [])<br> tags = optional(map(string), {})<br> }))</pre> | `[]` | no |
48+
49+
## Outputs
50+
51+
| Name | Description |
52+
|------|-------------|
53+
| <a name="output_arn"></a> [arn](#output\_arn) | The ARN of the service network. |
54+
| <a name="output_auth_type"></a> [auth\_type](#output\_auth\_type) | The type of authentication and authorization that manages client access to the service network. |
55+
| <a name="output_created_at"></a> [created\_at](#output\_created\_at) | Date and time that the service network was created, specified in ISO-8601 format. |
56+
| <a name="output_id"></a> [id](#output\_id) | The ID of the service network. |
57+
| <a name="output_name"></a> [name](#output\_name) | The name of the service network. |
58+
| <a name="output_service_associations"></a> [service\_associations](#output\_service\_associations) | The list of the service associations with the service network.<br> `id` - The ID of the association.<br> `arn` - The ARN of the Association.<br> `status` - The operations status. Valid Values are `CREATE_IN_PROGRESS`, `ACTIVE`, `DELETE_IN_PROGRESS`, `CREATE_FAILED`, `DELETE_FAILED`.<br> `created_by` - The principal that created the association.<br><br> `service` - The ARN (Amazon Resource Name) of the service. |
59+
| <a name="output_updated_at"></a> [updated\_at](#output\_updated\_at) | Date and time that the service network was last updated, specified in ISO-8601 format. |
60+
| <a name="output_vpc_associations"></a> [vpc\_associations](#output\_vpc\_associations) | The list of VPC associations with the service network.<br> `id` - The ID of the association.<br> `arn` - The ARN of the Association.<br> `status` - The operations status. Valid Values are `CREATE_IN_PROGRESS`, `ACTIVE`, `DELETE_IN_PROGRESS`, `CREATE_FAILED`, `DELETE_FAILED`.<br> `created_by` - The principal that created the association.<br><br> `vpc` - The ID of the VPC.<br> `security_groups` - A list of the IDs of the security groups. |
61+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
locals {
2+
metadata = {
3+
package = "terraform-aws-vpc-connectivity"
4+
version = trimspace(file("${path.module}/../../VERSION"))
5+
module = basename(path.module)
6+
name = data.aws_vpclattice_service_network.this.name
7+
}
8+
module_tags = var.module_tags_enabled ? {
9+
"module.terraform.io/package" = local.metadata.package
10+
"module.terraform.io/version" = local.metadata.version
11+
"module.terraform.io/name" = local.metadata.module
12+
"module.terraform.io/full-name" = "${local.metadata.package}/${local.metadata.module}"
13+
"module.terraform.io/instance" = local.metadata.name
14+
} : {}
15+
}
16+
17+
18+
# TODO: Get data source with service name
19+
# TODO: Get data source for VPC associations
20+
# TODO: Get data source for Service Network associations
21+
###################################################
22+
# Service Network for VPC Lattice
23+
###################################################
24+
25+
data "aws_vpclattice_service_network" "this" {
26+
service_network_identifier = var.id
27+
}
28+
29+
30+
###################################################
31+
# VPC Associations of Service Network
32+
###################################################
33+
34+
resource "aws_vpclattice_service_network_vpc_association" "this" {
35+
for_each = {
36+
for association in var.vpc_associations :
37+
association.vpc => association
38+
}
39+
40+
service_network_identifier = data.aws_vpclattice_service_network.this.id
41+
42+
vpc_identifier = each.key
43+
security_group_ids = each.value.security_groups
44+
45+
tags = merge(
46+
{
47+
"Name" = "${local.metadata.name}/${each.key}"
48+
},
49+
local.module_tags,
50+
var.tags,
51+
each.value.tags,
52+
)
53+
}
54+
55+
56+
###################################################
57+
# Service Associations of Service Network
58+
###################################################
59+
60+
resource "aws_vpclattice_service_network_service_association" "this" {
61+
for_each = {
62+
for association in var.service_associations :
63+
association.name => association
64+
}
65+
66+
service_network_identifier = data.aws_vpclattice_service_network.this.id
67+
68+
service_identifier = each.value.service
69+
70+
tags = merge(
71+
{
72+
"Name" = "${local.metadata.name}/${each.key}"
73+
},
74+
local.module_tags,
75+
var.tags,
76+
each.value.tags,
77+
)
78+
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
output "id" {
2+
description = "The ID of the service network."
3+
value = data.aws_vpclattice_service_network.this.id
4+
}
5+
6+
output "arn" {
7+
description = "The ARN of the service network."
8+
value = data.aws_vpclattice_service_network.this.arn
9+
}
10+
11+
output "name" {
12+
description = "The name of the service network."
13+
value = data.aws_vpclattice_service_network.this.name
14+
}
15+
16+
output "auth_type" {
17+
description = "The type of authentication and authorization that manages client access to the service network."
18+
value = data.aws_vpclattice_service_network.this.auth_type
19+
}
20+
21+
output "vpc_associations" {
22+
description = <<EOF
23+
The list of VPC associations with the service network.
24+
`id` - The ID of the association.
25+
`arn` - The ARN of the Association.
26+
`status` - The operations status. Valid Values are `CREATE_IN_PROGRESS`, `ACTIVE`, `DELETE_IN_PROGRESS`, `CREATE_FAILED`, `DELETE_FAILED`.
27+
`created_by` - The principal that created the association.
28+
29+
`vpc` - The ID of the VPC.
30+
`security_groups` - A list of the IDs of the security groups.
31+
EOF
32+
value = {
33+
for vpc, association in aws_vpclattice_service_network_vpc_association.this :
34+
vpc => {
35+
id = association.id
36+
arn = association.arn
37+
status = association.status
38+
created_by = association.created_by
39+
40+
vpc = vpc
41+
security_groups = association.security_group_ids
42+
}
43+
}
44+
}
45+
46+
output "service_associations" {
47+
description = <<EOF
48+
The list of the service associations with the service network.
49+
`id` - The ID of the association.
50+
`arn` - The ARN of the Association.
51+
`status` - The operations status. Valid Values are `CREATE_IN_PROGRESS`, `ACTIVE`, `DELETE_IN_PROGRESS`, `CREATE_FAILED`, `DELETE_FAILED`.
52+
`created_by` - The principal that created the association.
53+
54+
`service` - The ARN (Amazon Resource Name) of the service.
55+
EOF
56+
value = {
57+
for name, association in aws_vpclattice_service_network_service_association.this :
58+
name => {
59+
id = association.id
60+
arn = association.arn
61+
status = association.status
62+
created_by = association.created_by
63+
64+
service = association.service_identifier
65+
66+
domain = one(association.dns_entry[*].domain_name)
67+
zone_id = one(association.dns_entry[*].hosted_zone_id)
68+
custom_domain = association.custom_domain_name
69+
}
70+
}
71+
}
72+
73+
output "created_at" {
74+
description = "Date and time that the service network was created, specified in ISO-8601 format."
75+
value = data.aws_vpclattice_service_network.this.created_at
76+
}
77+
78+
output "updated_at" {
79+
description = "Date and time that the service network was last updated, specified in ISO-8601 format."
80+
value = data.aws_vpclattice_service_network.this.last_updated_at
81+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
locals {
2+
resource_group_name = (var.resource_group_name != ""
3+
? var.resource_group_name
4+
: join(".", [
5+
local.metadata.package,
6+
local.metadata.module,
7+
replace(local.metadata.name, "/[^a-zA-Z0-9_\\.-]/", "-"),
8+
])
9+
)
10+
}
11+
12+
13+
module "resource_group" {
14+
source = "tedilabs/misc/aws//modules/resource-group"
15+
version = "~> 0.10.0"
16+
17+
count = (var.resource_group_enabled && var.module_tags_enabled) ? 1 : 0
18+
19+
name = local.resource_group_name
20+
description = var.resource_group_description
21+
22+
query = {
23+
resource_tags = local.module_tags
24+
}
25+
26+
module_tags_enabled = false
27+
tags = merge(
28+
local.module_tags,
29+
var.tags,
30+
)
31+
}

0 commit comments

Comments
 (0)