Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add additional output security_group_arn #249

Merged
merged 3 commits into from
Aug 16, 2022

Conversation

dhoppe
Copy link
Contributor

@dhoppe dhoppe commented Aug 8, 2022

Description

  • The ARN of the security group
  • Update required version of AWS provider to >= 3.29

Motivation and Context

Fixes #247.

Breaking Changes

I think this requires a new release, because the new output is only available since version 3.29.

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects

complete:

Apply complete! Resources: 44 added, 0 changed, 0 destroyed.

Outputs:

security_group_arn = "arn:aws:ec2:eu-west-1:590606209411:security-group/sg-0444c3f9155890a0a"
security_group_description = "Security group with all available arguments set (this is just an example)"
security_group_id = "sg-0444c3f9155890a0a"
security_group_name = "complete-sg-20220808074808410500000002"
security_group_owner_id = "590606209411"
security_group_vpc_id = "vpc-09780c5d1816dfb9f"

computed:

Apply complete! Resources: 10 added, 0 changed, 0 destroyed.

Outputs:

security_group_arn = "arn:aws:ec2:eu-west-1:590606209411:security-group/sg-0fc266db9e3fbc80b"
security_group_description = "Security group with MySQL/Aurora port open for HTTP security group created above (computed)"
security_group_id = "sg-0fc266db9e3fbc80b"
security_group_name = "computed-mysql-sg-20220808080319588200000001"
security_group_owner_id = "590606209411"
security_group_vpc_id = "vpc-09780c5d1816dfb9f"

disabled:

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

security_group_arn = ""
security_group_id = ""

dynamic:

Apply complete! Resources: 5 added, 0 changed, 0 destroyed.

Outputs:

security_group_arn = "arn:aws:ec2:eu-west-1:590606209411:security-group/sg-08786fd7b2f028e15"
security_group_description = "Security group with HTTP port open for everyone, and HTTPS open just for the default security group"
security_group_id = "sg-08786fd7b2f028e15"
security_group_name = "dynamic-http-sg-20220808080943115200000001"
security_group_owner_id = "590606209411"
security_group_vpc_id = "vpc-09780c5d1816dfb9f"

http:

Apply complete! Resources: 24 added, 0 changed, 0 destroyed.

Outputs:

security_group_arn = "arn:aws:ec2:eu-west-1:590606209411:security-group/sg-0fd704743a5fc8375"
security_group_description = "Security group with HTTP ports open for everybody (IPv4 CIDR), egress ports are all world open"
security_group_id = "sg-0fd704743a5fc8375"
security_group_name = "http-sg-20220808081359706900000004"
security_group_owner_id = "590606209411"
security_group_vpc_id = "vpc-09780c5d1816dfb9f"

rules-only:

Apply complete! Resources: 4 added, 0 changed, 0 destroyed.

Outputs:

service_one_security_group_arn = "arn:aws:ec2:eu-west-1:590606209411:security-group/sg-02286e4a4e0e8b756"
service_one_security_group_id = "sg-02286e4a4e0e8b756"
service_tow_security_group_arn = "arn:aws:ec2:eu-west-1:590606209411:security-group/sg-0aafe86440d138bd7"
service_two_security_group_id = "sg-0aafe86440d138bd7"
  • I have executed pre-commit run -a on my pull request
➜ pre-commit run -a
Terraform fmt............................................................Passed
Terraform validate.......................................................Failed
- hook id: terraform_validate
- exit code: 1

Validation failed: modules/_templates
╷
│ Error: Reference to undeclared input variable
│
│   on main.tf line 16, in module "sg":
│   16:   ingress_rules = sort(compact(distinct(concat(var.auto_ingress_rules, var.ingress_rules, [""]))))
│
│ An input variable with the name "auto_ingress_rules" has not been declared.
│ This variable can be declared with a variable "auto_ingress_rules" {}
│ block.
╵
╷
│ Error: Reference to undeclared input variable
│
│   on main.tf line 19, in module "sg":
│   19:   ingress_with_self = concat(var.auto_ingress_with_self, var.ingress_with_self)
│
│ An input variable with the name "auto_ingress_with_self" has not been
│ declared. This variable can be declared with a variable
│ "auto_ingress_with_self" {} block.
╵
╷
│ Error: Reference to undeclared input variable
│
│   on main.tf line 41, in module "sg":
│   41:   computed_ingress_rules = sort(compact(distinct(concat(var.auto_computed_ingress_rules, var.computed_ingress_rules, [""]))))
│
│ An input variable with the name "auto_computed_ingress_rules" has not been
│ declared. This variable can be declared with a variable
│ "auto_computed_ingress_rules" {} block.
╵
╷
│ Error: Reference to undeclared input variable
│
│   on main.tf line 44, in module "sg":
│   44:   computed_ingress_with_self = concat(var.auto_computed_ingress_with_self, var.computed_ingress_with_self)
│
│ An input variable with the name "auto_computed_ingress_with_self" has not
│ been declared. This variable can be declared with a variable
│ "auto_computed_ingress_with_self" {} block.
╵
╷
│ Error: Reference to undeclared input variable
│
│   on main.tf line 58, in module "sg":
│   58:   number_of_computed_ingress_rules                         = var.auto_number_of_computed_ingress_rules + var.number_of_computed_ingress_rules
│
│ An input variable with the name "auto_number_of_computed_ingress_rules" has
│ not been declared. This variable can be declared with a variable
│ "auto_number_of_computed_ingress_rules" {} block.
╵
╷
│ Error: Reference to undeclared input variable
│
│   on main.tf line 59, in module "sg":
│   59:   number_of_computed_ingress_with_self                     = var.auto_number_of_computed_ingress_with_self + var.number_of_computed_ingress_with_self
│
│ An input variable with the name "auto_number_of_computed_ingress_with_self"
│ has not been declared. This variable can be declared with a variable
│ "auto_number_of_computed_ingress_with_self" {} block.
╵
╷
│ Error: Reference to undeclared input variable
│
│   on main.tf line 68, in module "sg":
│   68:   egress_rules = sort(compact(distinct(concat(var.auto_egress_rules, var.egress_rules, [""]))))
│
│ An input variable with the name "auto_egress_rules" has not been declared.
│ This variable can be declared with a variable "auto_egress_rules" {} block.
╵
╷
│ Error: Reference to undeclared input variable
│
│   on main.tf line 71, in module "sg":
│   71:   egress_with_self = concat(var.auto_egress_with_self, var.egress_with_self)
│
│ An input variable with the name "auto_egress_with_self" has not been
│ declared. This variable can be declared with a variable
│ "auto_egress_with_self" {} block.
╵
╷
│ Error: Reference to undeclared input variable
│
│   on main.tf line 93, in module "sg":
│   93:   computed_egress_rules = sort(compact(distinct(concat(var.auto_computed_egress_rules, var.computed_egress_rules, [""]))))
│
│ An input variable with the name "auto_computed_egress_rules" has not been
│ declared. This variable can be declared with a variable
│ "auto_computed_egress_rules" {} block.
╵
╷
│ Error: Reference to undeclared input variable
│
│   on main.tf line 96, in module "sg":
│   96:   computed_egress_with_self = concat(var.auto_computed_egress_with_self, var.computed_egress_with_self)
│
│ An input variable with the name "auto_computed_egress_with_self" has not
│ been declared. This variable can be declared with a variable
│ "auto_computed_egress_with_self" {} block.
╵
╷
│ Error: Reference to undeclared input variable
│
│   on main.tf line 110, in module "sg":
│  110:   number_of_computed_egress_rules                         = var.auto_number_of_computed_egress_rules + var.number_of_computed_egress_rules
│
│ An input variable with the name "auto_number_of_computed_egress_rules" has
│ not been declared. This variable can be declared with a variable
│ "auto_number_of_computed_egress_rules" {} block.
╵
╷
│ Error: Reference to undeclared input variable
│
│   on main.tf line 111, in module "sg":
│  111:   number_of_computed_egress_with_self                     = var.auto_number_of_computed_egress_with_self + var.number_of_computed_egress_with_self
│
│ An input variable with the name "auto_number_of_computed_egress_with_self"
│ has not been declared. This variable can be declared with a variable
│ "auto_number_of_computed_egress_with_self" {} block.
╵

Terraform docs...........................................................Passed
check for merge conflicts................................................Passed
fix end of files.........................................................Passed

* The ARN of the security group
* Update required version of AWS provider to >= 3.29
@dhoppe
Copy link
Contributor Author

dhoppe commented Aug 8, 2022

I will have a look at these undeclared input variables later.

@dhoppe
Copy link
Contributor Author

dhoppe commented Aug 8, 2022

I will have a look at these undeclared input variables later.

Fixed it by excluding modules/_templates from pre-commit hook terraform_validate.

@antonbabenko antonbabenko merged commit 44d8a25 into terraform-aws-modules:master Aug 16, 2022
@antonbabenko
Copy link
Member

Thanks @dhoppe !

antonbabenko pushed a commit that referenced this pull request Aug 16, 2022
## [4.10.0](v4.9.0...v4.10.0) (2022-08-16)

### Features

* Add additional output security_group_arn ([#249](#249)) ([44d8a25](44d8a25))
@antonbabenko
Copy link
Member

This PR is included in version 4.10.0 🎉

@dhoppe dhoppe deleted the add_output branch August 16, 2022 11:04
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add security group ARN attribute to the module output
2 participants