Skip to content

Commit

Permalink
add waf, nat, and iam
Browse files Browse the repository at this point in the history
  • Loading branch information
rucciva committed Feb 28, 2024
1 parent a837005 commit c0171ab
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 35 deletions.
34 changes: 17 additions & 17 deletions huaweicloud/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions huaweicloud/iam.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
data "huaweicloud_identity_users" "all" {}

data "huaweicloud_identity_permissions" "custom" {
type = "custom"
}

locals {
iam_users = data.huaweicloud_identity_users.all.users
iam_permissions = data.huaweicloud_identity_permissions.custom.permissions
}
18 changes: 4 additions & 14 deletions huaweicloud/nat.tf
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
data "huaweicloud_nat_gateway" "all" {
# WARN: unstable
# HuaweiCloud provider does not have list of nat and private nat data source
# So here we get it from route table
for_each = toset(distinct(flatten([
for v in data.huaweicloud_vpc_route_table.all : [
for r in v.route :
r.nexthop if r.type == "nat" && r.destination == "0.0.0.0/0"
]
])))

id = each.key
}
data "huaweicloud_nat_gateways" "all" {}
data "huaweicloud_nat_private_gateways" "all" {}

locals {
nat = values(data.huaweicloud_nat_gateway.all)
nat_gateways = data.huaweicloud_nat_gateways.all.gateways
nat_private_gateways = data.huaweicloud_nat_private_gateways.all.gateways
}
18 changes: 16 additions & 2 deletions huaweicloud/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,18 @@ output "evs_attachments" {
value = local.evs_attachments
}

output "nat" {
value = local.nat
output "iam_users" {
value = local.iam_users
}
output "iam_permission" {
value = local.iam_permissions
}

output "nat_gateways" {
value = local.nat_gateways
}
output "nat_private_gateways" {
value = local.nat_private_gateways
}

output "obs" {
Expand Down Expand Up @@ -78,3 +88,7 @@ output "vpc_subnets" {
output "vpc_route_tables" {
value = local.vpc_route_tables
}

output "waf_domains" {
value = local.waf_domains
}
2 changes: 1 addition & 1 deletion huaweicloud/version.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
huaweicloud = {
source = "huaweicloud/huaweicloud"
version = "1.57.0"
version = "1.61.1"
}
}
}
5 changes: 5 additions & 0 deletions huaweicloud/waf.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data "huaweicloud_waf_domains" "all" {}

locals {
waf_domains = data.huaweicloud_waf_domains.all.domains
}
2 changes: 1 addition & 1 deletion query.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail
dir=${1:-"."}

trap "rm '$dir/terraform.tfstate'" EXIT
terraform -chdir="$dir" init -reconfigure >/dev/null
terraform -chdir="$dir" init -reconfigure -upgrade >/dev/null
terraform -chdir="$dir" refresh >/dev/null
terraform -chdir="$dir" output -json |
jq 'with_entries(.value = .value.value)'

0 comments on commit c0171ab

Please sign in to comment.