Skip to content

Commit

Permalink
Merge pull request #25 from Lance52259/br_output_reference_fix
Browse files Browse the repository at this point in the history
chore(script): adjust the code style and output reference
  • Loading branch information
Lance52259 authored Nov 14, 2024
2 parents 778ed4a + 7f38570 commit 8bf9e52
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 41 deletions.
30 changes: 18 additions & 12 deletions examples/full_resource_inputs/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
output "vpc_id" {
description = "The ID of the VPC resource"
value = module.vpc_service.vpc_id
description = "The ID of the VPC resource"

value = module.vpc_service.vpc_id
}

output "vpc_cidr" {
description = "The CIDR block of the VPC resource"
value = module.vpc_service.vpc_cidr
description = "The CIDR block of the VPC resource"

value = module.vpc_service.vpc_cidr
}

output "subnet_cidrs" {
description = "The CIDR list of the subnet resources to which the VPC resource belongs"
value = module.vpc_service.subnet_cidrs
description = "The CIDR list of the subnet resources to which the VPC resource belongs"

value = module.vpc_service.subnet_cidrs
}

output "subnet_ids" {
description = "The ID list of the subnet resources to which the VPC resource belongs"
value = module.vpc_service.subnet_ids
description = "The ID list of the subnet resources to which the VPC resource belongs"

value = module.vpc_service.subnet_ids
}

output "security_group_id" {
description = "The ID of the security group resource"
value = module.vpc_service.security_group_id
description = "The ID of the security group resource"

value = module.vpc_service.security_group_id
}

output "security_group_rules" {
description = "All rules to which the security group resource belongs"
value = module.vpc_service.security_group_rules
description = "All rules to which the security group resource belongs"

value = module.vpc_service.security_group_rules
}
8 changes: 5 additions & 3 deletions examples/simple_security_group_rules/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
output "security_group_id" {
description = "The ID of the security group resource"
value = module.vpc_service.security_group_id

value = module.vpc_service.security_group_id
}

output "security_group_rules" {
description = "All rules to which the security group resource belongs"
value = module.vpc_service.security_group_rules
description = "All rules to which the security group resource belongs"

value = module.vpc_service.security_group_rules
}
20 changes: 12 additions & 8 deletions examples/simple_vpc_subnets/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
output "vpc_id" {
description = "The ID of the VPC resource"
value = module.vpc_service.vpc_id
description = "The ID of the VPC resource"

value = module.vpc_service.vpc_id
}

output "vpc_cidr" {
description = "The CIDR block of the VPC resource"
value = module.vpc_service.vpc_cidr
description = "The CIDR block of the VPC resource"

value = module.vpc_service.vpc_cidr
}

output "subnet_cidrs" {
description = "The CIDR list of the subnet resources to which the VPC resource belongs"
value = module.vpc_service.subnet_cidrs
description = "The CIDR list of the subnet resources to which the VPC resource belongs"

value = module.vpc_service.subnet_cidrs
}

output "subnet_ids" {
description = "The ID list of the subnet resources to which the VPC resource belongs"
value = module.vpc_service.subnet_ids
description = "The ID list of the subnet resources to which the VPC resource belongs"

value = module.vpc_service.subnet_ids
}
45 changes: 27 additions & 18 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,44 +1,53 @@
output "vpc_id" {
description = "The ID of the VPC resource"
value = try(huaweicloud_vpc.this[0].id, "")
description = "The ID of the VPC resource"

value = try(huaweicloud_vpc.this[0].id, "")
}

output "vpc_cidr" {
description = "The CIDR block of the VPC resource"
value = try(huaweicloud_vpc.this[0].id, "")
description = "The CIDR block of the VPC resource"

value = try(huaweicloud_vpc.this[0].id, "")
}

output "subnet_cidrs" {
description = "The CIDR list of the subnet resources to which the VPC resource belongs"
value = try(huaweicloud_vpc_subnet.this[*].cidr, [])
description = "The CIDR list of the subnet resources to which the VPC resource belongs"

value = try(huaweicloud_vpc_subnet.this[*].cidr, [])
}

output "subnet_ids" {
description = "The ID list of the subnet resources to which the VPC resource belongs"
value = try(huaweicloud_vpc_subnet.this[*].id, [])
description = "The ID list of the subnet resources to which the VPC resource belongs"

value = try(huaweicloud_vpc_subnet.this[*].id, [])
}

output "security_group_id" {
description = "The ID of the security group resource"
value = try(huaweicloud_networking_secgroup.this[0].id, "")
description = "The ID of the security group resource"

value = try(huaweicloud_networking_secgroup.this[0].id, "")
}

output "security_group_rules" {
description = "All rules to which the security group resource belongs"
value = try(data.huaweicloud_networking_secgroup_rules.this[0].rules, null)
description = "All rules to which the security group resource belongs"

value = try(data.huaweicloud_networking_secgroup_rules.this[*].rules, [])
}

output "queried_vpc_ids" {
description = "The ID list of the VPC resources for data-source query by resource name"
value = [for v in flatten(data.huaweicloud_vpcs.this[*].vpcs): v.id if contains(var.query_vpc_names, v.name)]
description = "The ID list of the VPC resources for data-source query by resource name"

value = [for v in flatten(data.huaweicloud_vpcs.this[*].vpcs): v.id if contains(var.query_vpc_names, v.name)]
}

output "queried_subnet_ids" {
description = "The ID list of the subnet resources for data-source query by resource name"
value = [for v in flatten(data.huaweicloud_vpc_subnets.this[*].subnets): v.id if contains(var.query_subnet_names, v.name)]
description = "The ID list of the subnet resources for data-source query by resource name"

value = [for v in flatten(data.huaweicloud_vpc_subnets.this[*].subnets): v.id if contains(var.query_subnet_names, v.name)]
}

output "queried_security_group_ids" {
description = "The ID list of the security group resources for data-source query by resource name"
value = [for v in flatten(data.huaweicloud_networking_secgroups.this[*].security_groups): v.id if contains(var.query_security_group_names, v.name)]
description = "The ID list of the security group resources for data-source query by resource name"

value = [for v in flatten(data.huaweicloud_networking_secgroups.this[*].security_groups): v.id if contains(var.query_security_group_names, v.name)]
}

0 comments on commit 8bf9e52

Please sign in to comment.