Skip to content

Commit 3219034

Browse files
authored
Fix OpenTofu execution as admin (#582)
Fetch authentication scope to retrieve the current project ID and use it for security groups. This makes it possible to apply OpenTofu using the admin role, which can be necessary for mapping instances to specific bare metal nodes.
1 parent 8dc121a commit 3219034

File tree

1 file changed

+8
-0
lines changed
  • environments/skeleton/{{cookiecutter.environment}}/tofu

1 file changed

+8
-0
lines changed

environments/skeleton/{{cookiecutter.environment}}/tofu/network.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,22 @@ data "openstack_networking_subnet_v2" "cluster_subnet" {
1313
name = each.value.subnet
1414
}
1515

16+
data "openstack_identity_auth_scope_v3" "scope" {
17+
# This is an arbitrary name which is only used as a unique identifier so an
18+
# actual token isn't used as the ID.
19+
name = "scope"
20+
}
21+
1622
data "openstack_networking_secgroup_v2" "login" {
1723
for_each = toset(var.login_security_groups)
1824

1925
name = each.key
26+
tenant_id = data.openstack_identity_auth_scope_v3.scope.project_id
2027
}
2128

2229
data "openstack_networking_secgroup_v2" "nonlogin" {
2330
for_each = toset(var.nonlogin_security_groups)
2431

2532
name = each.key
33+
tenant_id = data.openstack_identity_auth_scope_v3.scope.project_id
2634
}

0 commit comments

Comments
 (0)