Skip to content

Commit

Permalink
feat: add support for access tags (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewLemmond committed Jun 8, 2023
1 parent 2418e52 commit ff5dc23
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 33 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ module vsi {
resource_group_id = var.resource_group_id
prefix = var.prefix
tags = var.tags
access_tags = var.access_tags
vpc_id = var.vpc_id
subnets = var.subnets
image_id = var.image_id
Expand Down Expand Up @@ -142,6 +143,7 @@ No modules.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_access_tags"></a> [access\_tags](#input\_access\_tags) | A list of access tags to apply to the VSI resources created by the module. For more information, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial. | `list(string)` | `[]` | no |
| <a name="input_allow_ip_spoofing"></a> [allow\_ip\_spoofing](#input\_allow\_ip\_spoofing) | Allow IP spoofing on the primary network interface | `bool` | `false` | no |
| <a name="input_block_storage_volumes"></a> [block\_storage\_volumes](#input\_block\_storage\_volumes) | List describing the block storage volumes that will be attached to each vsi | <pre>list(<br> object({<br> name = string<br> profile = string<br> capacity = optional(number)<br> iops = optional(number)<br> encryption_key = optional(string)<br> })<br> )</pre> | `[]` | no |
| <a name="input_boot_volume_encryption_key"></a> [boot\_volume\_encryption\_key](#input\_boot\_volume\_encryption\_key) | CRN of boot volume encryption key | `string` | n/a | yes |
Expand Down
1 change: 1 addition & 0 deletions examples/default/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ module "slz_vsi" {
create_security_group = var.create_security_group
security_group = var.security_group
tags = var.resource_tags
access_tags = var.access_tags
subnets = module.slz_vpc.subnet_zone_list
vpc_id = module.slz_vpc.vpc_id
prefix = var.prefix
Expand Down
6 changes: 6 additions & 0 deletions examples/default/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ variable "resource_tags" {
default = null
}

variable "access_tags" {
type = list(string)
description = "A list of access tags to apply to the VSI resources created by the module."
default = []
}

variable "image_id" {
description = "Image ID used for VSI. Run 'ibmcloud is images' to find available images. Be aware that region is important for the image since the id's are different in each region."
type = string
Expand Down
1 change: 1 addition & 0 deletions load_balancer.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ resource "ibm_is_lb" "lb" {
security_groups = each.value.security_group == null ? null : [ibm_is_security_group.security_group[each.value.security_group.name].id]
resource_group = var.resource_group_id
tags = var.tags
access_tags = var.access_tags
}

##############################################################################
Expand Down
17 changes: 10 additions & 7 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ resource "ibm_is_instance" "vsi" {
user_data = var.user_data
keys = var.ssh_key_ids
tags = var.tags
access_tags = var.access_tags
lifecycle {
ignore_changes = [
image
Expand Down Expand Up @@ -123,20 +124,22 @@ resource "ibm_is_instance" "vsi" {
##############################################################################

resource "ibm_is_floating_ip" "vsi_fip" {
for_each = var.enable_floating_ip ? ibm_is_instance.vsi : {}
name = "${each.value.name}-fip"
target = each.value.primary_network_interface[0].id
tags = var.tags
for_each = var.enable_floating_ip ? ibm_is_instance.vsi : {}
name = "${each.value.name}-fip"
target = each.value.primary_network_interface[0].id
tags = var.tags
access_tags = var.access_tags
}

resource "ibm_is_floating_ip" "secondary_fip" {
for_each = length(var.secondary_floating_ips) == 0 ? {} : {
for interface in local.secondary_fip_list :
(interface.name) => interface
}
name = each.key
target = each.value.target
tags = var.tags
name = each.key
target = each.value.target
tags = var.tags
access_tags = var.access_tags
}

##############################################################################
80 changes: 54 additions & 26 deletions module-metadata.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
{
"path": ".",
"variables": {
"access_tags": {
"name": "access_tags",
"type": "list(string)",
"description": "A list of access tags to apply to the VSI resources created by the module. For more information, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial.",
"default": [],
"source": [
"ibm_is_floating_ip.secondary_fip.access_tags",
"ibm_is_floating_ip.vsi_fip.access_tags",
"ibm_is_instance.vsi.access_tags",
"ibm_is_lb.lb.access_tags",
"ibm_is_security_group.security_group.access_tags",
"ibm_is_volume.volume.access_tags"
],
"pos": {
"filename": "variables.tf",
"line": 26
},
"computed": true,
"elem": {
"type": "TypeString"
}
},
"allow_ip_spoofing": {
"name": "allow_ip_spoofing",
"type": "bool",
"description": "Allow IP spoofing on the primary network interface",
"default": false,
"pos": {
"filename": "variables.tf",
"line": 93
"line": 106
}
},
"block_storage_volumes": {
Expand All @@ -21,7 +43,7 @@
],
"pos": {
"filename": "variables.tf",
"line": 174
"line": 187
}
},
"boot_volume_encryption_key": {
Expand All @@ -31,7 +53,7 @@
"required": true,
"pos": {
"filename": "variables.tf",
"line": 82
"line": 95
}
},
"create_security_group": {
Expand All @@ -41,7 +63,7 @@
"required": true,
"pos": {
"filename": "variables.tf",
"line": 99
"line": 112
}
},
"enable_floating_ip": {
Expand All @@ -54,7 +76,7 @@
],
"pos": {
"filename": "variables.tf",
"line": 87
"line": 100
}
},
"image_id": {
Expand All @@ -67,7 +89,7 @@
],
"pos": {
"filename": "variables.tf",
"line": 57
"line": 70
},
"immutable": true,
"computed": true
Expand All @@ -79,7 +101,7 @@
"default": [],
"pos": {
"filename": "variables.tf",
"line": 193
"line": 206
}
},
"machine_type": {
Expand All @@ -92,7 +114,7 @@
],
"pos": {
"filename": "variables.tf",
"line": 67
"line": 80
},
"computed": true
},
Expand Down Expand Up @@ -138,7 +160,7 @@
"default": false,
"pos": {
"filename": "variables.tf",
"line": 359
"line": 372
}
},
"secondary_floating_ips": {
Expand All @@ -151,7 +173,7 @@
],
"pos": {
"filename": "variables.tf",
"line": 348
"line": 361
}
},
"secondary_security_groups": {
Expand All @@ -161,7 +183,7 @@
"default": [],
"pos": {
"filename": "variables.tf",
"line": 327
"line": 340
}
},
"secondary_subnets": {
Expand All @@ -171,7 +193,7 @@
"default": [],
"pos": {
"filename": "variables.tf",
"line": 308
"line": 321
}
},
"secondary_use_vsi_security_group": {
Expand All @@ -181,7 +203,7 @@
"default": false,
"pos": {
"filename": "variables.tf",
"line": 321
"line": 334
}
},
"security_group": {
Expand All @@ -191,7 +213,7 @@
"required": true,
"pos": {
"filename": "variables.tf",
"line": 104
"line": 117
}
},
"security_group_ids": {
Expand All @@ -201,7 +223,7 @@
"default": [],
"pos": {
"filename": "variables.tf",
"line": 158
"line": 171
}
},
"ssh_key_ids": {
Expand All @@ -214,7 +236,7 @@
],
"pos": {
"filename": "variables.tf",
"line": 62
"line": 75
},
"elem": {
"type": "TypeString"
Expand All @@ -230,7 +252,7 @@
],
"pos": {
"filename": "variables.tf",
"line": 38
"line": 51
}
},
"tags": {
Expand Down Expand Up @@ -268,7 +290,7 @@
],
"pos": {
"filename": "variables.tf",
"line": 77
"line": 90
},
"immutable": true
},
Expand All @@ -284,7 +306,7 @@
],
"pos": {
"filename": "variables.tf",
"line": 33
"line": 46
},
"immutable": true,
"computed": true
Expand All @@ -296,7 +318,7 @@
"required": true,
"pos": {
"filename": "variables.tf",
"line": 72
"line": 85
}
}
},
Expand Down Expand Up @@ -367,6 +389,7 @@
"type": "ibm_is_floating_ip",
"name": "secondary_fip",
"attributes": {
"access_tags": "access_tags",
"for_each": "secondary_floating_ips",
"tags": "tags"
},
Expand All @@ -375,14 +398,15 @@
},
"pos": {
"filename": "main.tf",
"line": 132
"line": 134
}
},
"ibm_is_floating_ip.vsi_fip": {
"mode": "managed",
"type": "ibm_is_floating_ip",
"name": "vsi_fip",
"attributes": {
"access_tags": "access_tags",
"for_each": "enable_floating_ip",
"tags": "tags"
},
Expand All @@ -391,14 +415,15 @@
},
"pos": {
"filename": "main.tf",
"line": 125
"line": 126
}
},
"ibm_is_instance.vsi": {
"mode": "managed",
"type": "ibm_is_instance",
"name": "vsi",
"attributes": {
"access_tags": "access_tags",
"image": "image_id",
"keys": "ssh_key_ids",
"profile": "machine_type",
Expand All @@ -421,6 +446,7 @@
"type": "ibm_is_lb",
"name": "lb",
"attributes": {
"access_tags": "access_tags",
"name": "prefix",
"resource_group": "resource_group_id",
"subnets": "subnets",
Expand All @@ -443,7 +469,7 @@
},
"pos": {
"filename": "load_balancer.tf",
"line": 80
"line": 81
}
},
"ibm_is_lb_pool.pool": {
Expand All @@ -458,7 +484,7 @@
},
"pos": {
"filename": "load_balancer.tf",
"line": 29
"line": 30
}
},
"ibm_is_lb_pool_member.pool_members": {
Expand All @@ -470,14 +496,15 @@
},
"pos": {
"filename": "load_balancer.tf",
"line": 64
"line": 65
}
},
"ibm_is_security_group.security_group": {
"mode": "managed",
"type": "ibm_is_security_group",
"name": "security_group",
"attributes": {
"access_tags": "access_tags",
"resource_group": "resource_group_id",
"tags": "tags",
"vpc": "vpc_id"
Expand All @@ -499,14 +526,15 @@
},
"pos": {
"filename": "security_group.tf",
"line": 62
"line": 63
}
},
"ibm_is_volume.volume": {
"mode": "managed",
"type": "ibm_is_volume",
"name": "volume",
"attributes": {
"access_tags": "access_tags",
"tags": "tags"
},
"provider": {
Expand Down
Loading

0 comments on commit ff5dc23

Please sign in to comment.