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: Use Security Group 4.x Module #94

Merged
merged 80 commits into from
Nov 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
2480f55
bugfix: secondary_gids ignored in acces point creation
juan-acevedo-ntt Jul 5, 2021
463a7e6
Auto Format
cloudpossebot Jul 5, 2021
c71615e
fix format
juan-acevedo-ntt Jul 5, 2021
2adaad7
Merge branch 'master' of https://github.com/juan-acevedo-ntt/terrafor…
juan-acevedo-ntt Jul 5, 2021
68ba2cb
Add efs_backup_policy_enabled
nitrocode Jul 9, 2021
56c827b
Add aws_efs_backup_policy
nitrocode Jul 9, 2021
e6c6f8e
Auto Format
cloudpossebot Jul 9, 2021
3c1614b
Merge branch 'master' into master
juan-acevedo-ntt Aug 23, 2021
b79fa55
Make posix_user and creation_info optional in aws_efs_access_point
jgournet Sep 17, 2021
9630420
Auto Format
cloudpossebot Sep 17, 2021
cfb0ade
Add support for argument availability_zone_name
Sep 27, 2021
de26392
Skip bridgecrew check BC_AWS_GENERAL_48
Sep 27, 2021
e0ce79f
Update availability_zone_name description
Sep 27, 2021
c3fdb24
chore: readme updates
Sep 27, 2021
eae188b
Merge branch 'master' into efs_backup_policy
nitrocode Nov 5, 2021
8c8c177
Add transition_to_primary_storage_class
nitrocode Nov 5, 2021
65329f0
Add transition_to_primary_storage_class
nitrocode Nov 5, 2021
2b85ea6
Auto Format
cloudpossebot Nov 5, 2021
97771b0
Add transition_to_primary_storage_class to test
nitrocode Nov 5, 2021
39533d6
Revert "Update context.tf from origin source (#87)"
nitrocode Nov 5, 2021
4c4f1d0
Revert "feat: use security-group module instead of resource (#79)"
nitrocode Nov 5, 2021
c3fffc5
Use security group 4.0
nitrocode Nov 5, 2021
e9cbb11
Merge remote-tracking branch 'origin/efs_backup_policy' into security…
nitrocode Nov 5, 2021
df208e5
Support availability_zone_name
nitrocode Nov 5, 2021
0d6cea0
Support transition_to_primary_storage_class
nitrocode Nov 5, 2021
94b13a5
Change secondary_gids to list
nitrocode Nov 5, 2021
37fe5a3
Auto Format
cloudpossebot Nov 5, 2021
41629a6
Use a local for secondary_gids
nitrocode Nov 5, 2021
357e2ee
Update main.tf
nitrocode Nov 5, 2021
5ce0573
Correct posix users type
nitrocode Nov 5, 2021
14f8785
Change transition_* to empty strings
nitrocode Nov 5, 2021
9aa87f8
Auto Format
cloudpossebot Nov 5, 2021
73615c7
Change transition_* to default to empty string
nitrocode Nov 5, 2021
9e9acc4
Update main.tf
nitrocode Nov 5, 2021
d531e32
Split on comma
nitrocode Nov 5, 2021
da74802
Update main.tf
nitrocode Nov 5, 2021
de3c0ff
Merge remote-tracking branch 'origin/transition_to_primary_storage_cl…
nitrocode Nov 5, 2021
90edd9d
Update main.tf
nitrocode Nov 5, 2021
8b9bcc7
Update main.tf
nitrocode Nov 5, 2021
578cd2e
Merge remote-tracking branch 'juan-acevedo-ntt/master' into security-…
nitrocode Nov 5, 2021
0eb78ba
Merge remote-tracking branch 'jgournet/master' into security-group-4
nitrocode Nov 5, 2021
ac47ed7
Auto Format
cloudpossebot Nov 5, 2021
bad7a5c
Simplify true : false statement
nitrocode Nov 5, 2021
5562116
Use security_group_name instead of suffix
nitrocode Nov 8, 2021
db981a4
Convert transition vars to list(string)
nitrocode Nov 8, 2021
5624769
Set security_group_create_before_destroy to true
nitrocode Nov 8, 2021
8b2d508
Auto Format
cloudpossebot Nov 8, 2021
1482f1e
docs: Convert transition vars to list(string)
nitrocode Nov 8, 2021
afee56c
Convert zone_id to a list
nitrocode Nov 8, 2021
842dfbb
docs: Convert zone_id to a list
nitrocode Nov 8, 2021
e207eb1
Auto Format
cloudpossebot Nov 8, 2021
6d18f38
Add more to the access_points var description
nitrocode Nov 8, 2021
6b0ff18
posix_user dynamic uses correct for_each val
nitrocode Nov 8, 2021
313ce47
Auto Format
cloudpossebot Nov 8, 2021
a8f0f08
docs: make note of these changes
nitrocode Nov 8, 2021
387cd5b
Small fixes
nitrocode Nov 8, 2021
3faa67d
Auto Format
cloudpossebot Nov 8, 2021
c818884
Set kms_key_id to use list(string)
nitrocode Nov 8, 2021
4e6f5ff
Auto Format
cloudpossebot Nov 8, 2021
25f90da
Add missing type to provisioned_throughput_in_mibps
nitrocode Nov 8, 2021
2ff1c36
Fix examples/complete
nitrocode Nov 8, 2021
aa81071
zone_id remains optional
nitrocode Nov 8, 2021
83c9368
zone_id remains optional
nitrocode Nov 8, 2021
e02b640
Auto Format
cloudpossebot Nov 8, 2021
46b8e50
posix_user => posix_users
nitrocode Nov 8, 2021
eb2259c
Set only one transition*
nitrocode Nov 8, 2021
025b978
Fix test using create_before_destroy = false
nitrocode Nov 8, 2021
2ebafd9
docs: Add security_group_change_before_destroy
nitrocode Nov 8, 2021
47c38e2
set availability_zone_name to list(string)
nitrocode Nov 8, 2021
b649e43
Auto Format
cloudpossebot Nov 8, 2021
877badf
Update docs/migration-0.30.1-0.32.x+.md
nitrocode Nov 8, 2021
71a2a43
Update main.tf
nitrocode Nov 8, 2021
7a9a842
Update variables.tf
nitrocode Nov 8, 2021
e99b14e
Revert availability_zone_name and kms_key_id to string type
Nuru Nov 9, 2021
2ca5da4
Auto Format
cloudpossebot Nov 9, 2021
58ea231
Add standard input `associated_security_group_ids`
Nuru Nov 10, 2021
8b1c4e7
Update docs/migration-0.30.1-0.32.x+.md
nitrocode Nov 10, 2021
934a263
Update docs/migration-0.30.1-0.32.x+.md
nitrocode Nov 10, 2021
d05be79
Fix README note
nitrocode Nov 10, 2021
4ad1343
Auto Format
cloudpossebot Nov 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "feat: use security-group module instead of resource (#79)"
This reverts commit 2652b41.
  • Loading branch information
nitrocode committed Nov 5, 2021
commit 4c4f1d04cc69c62effeee5d2f982d969ec58845c
140 changes: 69 additions & 71 deletions README.md

Large diffs are not rendered by default.

18 changes: 8 additions & 10 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ usage: |-
# Cloud Posse recommends pinning every module to a specific version
# version = "x.x.x"

namespace = "eg"
stage = "test"
name = "app"
region = "us-west-1"
vpc_id = var.vpc_id
subnets = var.private_subnets
security_groups = [var.security_group_id]
zone_id = var.aws_route53_dns_zone_id
namespace = "eg"
stage = "test"
name = "app"
region = "us-west-1"
vpc_id = var.vpc_id
subnets = var.private_subnets
security_groups = [var.security_group_id]
zone_id = var.aws_route53_dns_zone_id
}
```

Expand All @@ -80,5 +80,3 @@ contributors:
github: "maokomioko"
- name: "Josh Myers"
github: "joshmyers"
- name: "Vladimir Syromyatnikov"
github: "SweetOps"
112 changes: 55 additions & 57 deletions docs/terraform.md

Large diffs are not rendered by default.

27 changes: 4 additions & 23 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,29 +28,10 @@ module "subnets" {
module "efs" {
source = "../../"

region = var.region
vpc_id = module.vpc.vpc_id
subnets = module.subnets.private_subnet_ids
security_group_rules = [
{
type = "egress"
from_port = 0
to_port = 65535
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
source_security_group_id = null
description = "Allow all egress trafic"
},
{
type = "ingress"
from_port = 2049
to_port = 2049
protocol = "tcp"
cidr_blocks = []
source_security_group_id = module.vpc.vpc_default_security_group_id
description = "Allow ingress traffic to EFS from trusted Security Groups"
}
]
region = var.region
vpc_id = module.vpc.vpc_id
subnets = module.subnets.private_subnet_ids
security_groups = [module.vpc.vpc_default_security_group_id]

context = module.this.context
}
68 changes: 47 additions & 21 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
locals {
dns_name = "${join("", aws_efs_file_system.default.*.id)}.efs.${var.region}.amazonaws.com"
security_group_enabled = module.this.enabled && var.security_group_enabled
dns_name = "${join("", aws_efs_file_system.default.*.id)}.efs.${var.region}.amazonaws.com"
}

resource "aws_efs_file_system" "default" {
nitrocode marked this conversation as resolved.
Show resolved Hide resolved
nitrocode marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -21,16 +20,11 @@ resource "aws_efs_file_system" "default" {
}

resource "aws_efs_mount_target" "default" {
count = module.this.enabled && length(var.subnets) > 0 ? length(var.subnets) : 0
file_system_id = join("", aws_efs_file_system.default.*.id)
ip_address = var.mount_target_ip_address
subnet_id = var.subnets[count.index]
security_groups = compact(
sort(concat(
[module.security_group.id],
var.security_groups
))
)
count = module.this.enabled && length(var.subnets) > 0 ? length(var.subnets) : 0
file_system_id = join("", aws_efs_file_system.default.*.id)
ip_address = var.mount_target_ip_address
subnet_id = var.subnets[count.index]
security_groups = [join("", aws_security_group.efs.*.id)]
}

resource "aws_efs_access_point" "default" {
Expand All @@ -57,17 +51,49 @@ resource "aws_efs_access_point" "default" {
tags = module.this.tags
}

module "security_group" {
source = "cloudposse/security-group/aws"
version = "0.3.1"
resource "aws_security_group" "efs" {
count = module.this.enabled ? 1 : 0
name = format("%s-efs", module.this.id)
description = "EFS Security Group"
vpc_id = var.vpc_id

use_name_prefix = var.security_group_use_name_prefix
rules = var.security_group_rules
vpc_id = var.vpc_id
description = var.security_group_description
lifecycle {
create_before_destroy = true
}

enabled = local.security_group_enabled
context = module.this.context
tags = module.this.tags
}

resource "aws_security_group_rule" "ingress_security_groups" {
count = module.this.enabled ? length(var.security_groups) : 0
description = "Allow inbound traffic from existing security groups"
type = "ingress"
from_port = "2049" # NFS
to_port = "2049"
protocol = "tcp"
source_security_group_id = var.security_groups[count.index]
security_group_id = join("", aws_security_group.efs.*.id)
}

resource "aws_security_group_rule" "ingress_cidr_blocks" {
count = module.this.enabled && length(var.allowed_cidr_blocks) > 0 ? 1 : 0
description = "Allow inbound traffic from CIDR blocks"
type = "ingress"
from_port = "2049" # NFS
to_port = "2049"
protocol = "tcp"
cidr_blocks = var.allowed_cidr_blocks
security_group_id = join("", aws_security_group.efs.*.id)
}

resource "aws_security_group_rule" "egress" {
count = module.this.enabled ? 1 : 0
type = "egress"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
security_group_id = join("", aws_security_group.efs.*.id)
}

module "dns" {
Expand Down
6 changes: 3 additions & 3 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ output "network_interface_ids" {
}

output "security_group_id" {
value = module.security_group.id
value = join("", aws_security_group.efs.*.id)
description = "EFS Security Group ID"
}

output "security_group_arn" {
value = module.security_group.arn
value = join("", aws_security_group.efs.*.arn)
description = "EFS Security Group ARN"
}

output "security_group_name" {
value = module.security_group.name
value = join("", aws_security_group.efs.*.name)
description = "EFS Security Group name"
}
12 changes: 1 addition & 11 deletions test/src/examples_complete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,7 @@ func TestExamplesComplete(t *testing.T) {

// Run `terraform output` to get the value of an output variable
securityGroupName := terraform.Output(t, terraformOptions, "security_group_name")
expectedSecurityGroupName := "eg-test-efs-test-" + randId
expectedSecurityGroupName := "eg-test-efs-test-" + randId + "-efs"
// Verify we're getting back the outputs we expect
assert.Equal(t, expectedSecurityGroupName, securityGroupName)

// Run `terraform output` to get the value of an output variable
securityGroupID := terraform.Output(t, terraformOptions, "security_group_id")
// Verify we're getting back the outputs we expect
assert.Contains(t, securityGroupID, "sg-", "SG ID should contains substring 'sg-'")

// Run `terraform output` to get the value of an output variable
securityGroupARN := terraform.Output(t, terraformOptions, "security_group_arn")
// Verify we're getting back the outputs we expect
assert.Contains(t, securityGroupARN, "arn:aws:ec2", "SG ID should contains substring 'arn:aws:ec2'")
}
3 changes: 1 addition & 2 deletions test/src/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/cloudposse/terraform-aws-efs
go 1.13

require (
github.com/gruntwork-io/gruntwork-cli v0.7.0 // indirect
github.com/gruntwork-io/terratest v0.34.7
github.com/gruntwork-io/terratest v0.31.4
github.com/stretchr/testify v1.6.1
)
Loading