Skip to content

Commit 889c315

Browse files
committed
Use external module for EFS
1 parent 8cf6032 commit 889c315

36 files changed

+223
-532
lines changed

.github/workflows/tfsec.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
push:
1010
branches: [ "main" ]
1111
pull_request:
12-
branches: [ "main" ]
12+
branches: [ "main" ]
1313
schedule:
1414
- cron: '39 18 * * 2'
1515

@@ -29,10 +29,10 @@ jobs:
2929
- name: Run tfsec
3030
uses: aquasecurity/tfsec-sarif-action@9a83b5c3524f825c020e356335855741fd02745f
3131
with:
32-
sarif_file: tfsec.sarif
32+
sarif_file: tfsec.sarif
3333

3434
- name: Upload SARIF file
3535
uses: github/codeql-action/upload-sarif@v2
3636
with:
3737
# Path to SARIF file relative to the root of the repository
38-
sarif_file: tfsec.sarif
38+
sarif_file: tfsec.sarif

README-PORTABLE.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ The solution has following features and benefits:
2929

3030
- The target AWS Account and AWS Region are identified.
3131
- The AWS User/Role executing the Terraform scripts must have permissions to provision the target resources.
32-
- The Terraform CLI (`version = ">= 1.0.4"`) is installed.
32+
- The [Terraform CLI](https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started) (`version = ">= 1.1.9"`) is installed.
33+
- The [Python 3.9+](https://www.python.org/downloads/) is installed.
34+
- AWS SDK for Python [boto3 1.24+](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html#installation) is installed.
3335
- Terraform backend provider and state locking providers are identified and bootstrapped.
3436
- An [example bootstrap](https://github.com/aws-samples/aws-tf-transfer-sftp-efs/tree/main/bootstrap) module/example is provided that provisions an Amazon S3 bucket for Terraform state storage and Amazon DynamoDB table for Terraform state locking.
3537
- The Amazon S3 bucket name has to be globally unique.
@@ -49,7 +51,10 @@ The solution has following features and benefits:
4951
## Usage
5052
5153
- Use the module via [GitHub source](https://www.terraform.io/language/modules/sources#github) or copy the module into your repository.
52-
- Incorporate the module in your CI/CD pipeline as appropriate.
54+
- Incorporate the module in your infrastructure/storage [CI](https://aws.amazon.com/devops/continuous-integration/)/[CD](https://aws.amazon.com/devops/continuous-delivery/) [pipeline](https://docs.aws.amazon.com/codepipeline/latest/userguide/concepts.html) as appropriate.
55+
- This solution uses following external modules
56+
- [aws-tf-kms](https://github.com/aws-samples/aws-tf-kms) to provision AWS KMS Key, if encryption is enabled and `kms_alias` is not provided.
57+
- [aws-tf-efs](https://github.com/aws-samples/aws-tf-efs) to provision Amazon EFS or EFS Access Point, if `efs_id` is null or `efs_ap_id` is null.
5358
5459
## Scenarios
5560

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ The solution has following features and benefits:
2929

3030
- The target AWS Account and AWS Region are identified.
3131
- The AWS User/Role executing the Terraform scripts must have permissions to provision the target resources.
32-
- The Terraform CLI (`version = ">= 1.0.4"`) is installed.
32+
- The [Terraform CLI](https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started) (`version = ">= 1.1.9"`) is installed.
33+
- The [Python 3.9+](https://www.python.org/downloads/) is installed.
34+
- AWS SDK for Python [boto3 1.24+](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/quickstart.html#installation) is installed.
3335
- Terraform backend provider and state locking providers are identified and bootstrapped.
3436
- An [example bootstrap](./bootstrap) module/example is provided that provisions an Amazon S3 bucket for Terraform state storage and Amazon DynamoDB table for Terraform state locking.
3537
- The Amazon S3 bucket name has to be globally unique.
@@ -49,7 +51,10 @@ The solution has following features and benefits:
4951
## Usage
5052
5153
- Use the module via [GitHub source](https://www.terraform.io/language/modules/sources#github) or copy the module into your repository.
52-
- Incorporate the module in your CI/CD pipeline as appropriate.
54+
- Incorporate the module in your infrastructure/storage [CI](https://aws.amazon.com/devops/continuous-integration/)/[CD](https://aws.amazon.com/devops/continuous-delivery/) [pipeline](https://docs.aws.amazon.com/codepipeline/latest/userguide/concepts.html) as appropriate.
55+
- This solution uses following external modules
56+
- [aws-tf-kms](https://github.com/aws-samples/aws-tf-kms) to provision AWS KMS Key, if encryption is enabled and `kms_alias` is not provided.
57+
- [aws-tf-efs](https://github.com/aws-samples/aws-tf-efs) to provision Amazon EFS or EFS Access Point, if `efs_id` is null or `efs_ap_id` is null.
5358
5459
## Scenarios
5560

examples/efs/scenario1/.terraform.lock.hcl

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/efs/scenario1/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ No providers.
5050
5151
| Name | Source | Version |
5252
|------|--------|---------|
53-
| <a name="module_common_efs"></a> [common\_efs](#module\_common\_efs) | ../../../modules/aws/efs | n/a |
53+
| <a name="module_common_efs"></a> [common\_efs](#module\_common\_efs) | github.com/aws-samples/aws-tf-efs//modules/aws/efs | v1.0.0 |
5454
5555
## Resources
5656
@@ -66,7 +66,7 @@ No resources.
6666
| <a name="input_subnet_tags"></a> [subnet\_tags](#input\_subnet\_tags) | Tags to discover target subnets in the VPC, these tags should identify one or more subnets | `map(string)` | n/a | yes |
6767
| <a name="input_tags"></a> [tags](#input\_tags) | Common and mandatory tags for the resources | `map(string)` | n/a | yes |
6868
| <a name="input_vpc_tags"></a> [vpc\_tags](#input\_vpc\_tags) | Tags to discover target VPC, these tags should uniquely identify a VPC | `map(string)` | n/a | yes |
69-
| <a name="input_efs_access_point_specs"></a> [efs\_access\_point\_specs](#input\_efs\_access\_point\_specs) | List of EFS Access Point Specs to be created. It can be empty list. | <pre>list(object({<br> efs_name = string # unique name e.g. common<br> efs_ap = string # unique name e.g. common_sftp<br> uid = number<br> gid = number<br> root_path = string # e.g. /{env}/{project}/{purpose}/{name}<br> owner_uid = number # e.g. 0<br> owner_gid = number # e.g. 0<br> root_permission = string # e.g. 0755<br> }))</pre> | `[]` | no |
69+
| <a name="input_efs_access_point_specs"></a> [efs\_access\_point\_specs](#input\_efs\_access\_point\_specs) | List of EFS Access Point Specs to be created. It can be empty list. | <pre>list(object({<br> efs_name = string # unique name e.g. common<br> efs_ap = string # unique name e.g. common_sftp<br> uid = number<br> gid = number<br> secondary_gids = list(number)<br> root_path = string # e.g. /{env}/{project}/{purpose}/{name}<br> owner_uid = number # e.g. 0<br> owner_gid = number # e.g. 0<br> root_permission = string # e.g. 0755<br> principal_arns = list(string)<br> }))</pre> | `[]` | no |
7070
| <a name="input_efs_id"></a> [efs\_id](#input\_efs\_id) | EFS File System Id, if not provided a new EFS will be created | `string` | `null` | no |
7171
| <a name="input_kms_alias"></a> [kms\_alias](#input\_kms\_alias) | KMS Alias to discover KMS for EFS encryption, if not provided a new CMK will be created | `string` | `""` | no |
7272
| <a name="input_security_group_tags"></a> [security\_group\_tags](#input\_security\_group\_tags) | Tags used to discover EFS Security Group, if not provided new EFS security group will be created | `map(string)` | `null` | no |

examples/efs/scenario1/main.tf

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module "common_efs" {
2-
source = "../../../modules/aws/efs"
2+
source = "github.com/aws-samples/aws-tf-efs//modules/aws/efs?ref=v1.0.0"
33

44
region = var.region
55

@@ -14,18 +14,18 @@ module "common_efs" {
1414
kms_alias = var.kms_alias
1515
kms_admin_roles = ["Admin"]
1616

17-
efs_specs = [
18-
{
19-
name = "common"
20-
efs_id = var.efs_id
21-
encrypted = true
22-
performance_mode = "generalPurpose"
23-
transition_to_ia = "AFTER_7_DAYS"
24-
backup_plan = "EVERY-DAY"
25-
# If security_group_tags is null, EFS security group is created
26-
security_group_tags = var.security_group_tags
27-
}
28-
]
17+
# If security_group_tags is null, EFS security group is created
18+
security_group_tags = var.security_group_tags
19+
20+
efs_name = "common"
21+
efs_id = var.efs_id
22+
encrypted = true
23+
performance_mode = "generalPurpose"
24+
transition_to_ia = "AFTER_7_DAYS"
25+
26+
efs_tags = {
27+
"BackupPlan" = "EVERY-DAY"
28+
}
2929

3030
efs_access_point_specs = var.efs_access_point_specs
3131
}

examples/efs/scenario1/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ output "efs_ap" {
1010

1111
output "efs_kms" {
1212
description = "KMS Keys created for EFS"
13-
value = module.common_efs.efs_kms
13+
value = module.common_efs.efs_kms_aliases
1414
}

examples/efs/scenario1/terraform.tfvars

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ region = "us-east-1"
66
/*---------------------------------------------------------
77
Common Variables
88
---------------------------------------------------------*/
9-
project = "scenario1-efs"
9+
project = "scenario1-efs-sftp"
1010
env_name = "dev"
1111
tags = {
1212
Env = "DEV"
13-
Project = "scenario1-efs"
13+
Project = "scenario1-efs-sftp"
1414
}
1515

1616
/*---------------------------------------------------------
@@ -40,9 +40,11 @@ efs_access_point_specs = [
4040
efs_ap = "sftp_scenario1"
4141
uid = 0
4242
gid = 0
43-
root_path = "/dev/scenario1-efs/sftp/common"
43+
secondary_gids = []
44+
root_path = "/dev/scenario1-efs-sftp/sftp/common"
4445
owner_uid = 0
4546
owner_gid = 0
4647
root_permission = "0755"
48+
principal_arns = ["*"]
4749
}
4850
]

examples/efs/scenario1/variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ variable "efs_access_point_specs" {
6565
efs_ap = string # unique name e.g. common_sftp
6666
uid = number
6767
gid = number
68+
secondary_gids = list(number)
6869
root_path = string # e.g. /{env}/{project}/{purpose}/{name}
6970
owner_uid = number # e.g. 0
7071
owner_gid = number # e.g. 0
7172
root_permission = string # e.g. 0755
73+
principal_arns = list(string)
7274
}))
7375
default = []
7476
}

examples/efs/scenario2/.terraform.lock.hcl

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/efs/scenario2/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ No providers.
5050
5151
| Name | Source | Version |
5252
|------|--------|---------|
53-
| <a name="module_common_efs"></a> [common\_efs](#module\_common\_efs) | ../../../modules/aws/efs | n/a |
53+
| <a name="module_common_efs"></a> [common\_efs](#module\_common\_efs) | github.com/aws-samples/aws-tf-efs//modules/aws/efs | v1.0.0 |
5454
5555
## Resources
5656
@@ -66,7 +66,7 @@ No resources.
6666
| <a name="input_subnet_tags"></a> [subnet\_tags](#input\_subnet\_tags) | Tags to discover target subnets in the VPC, these tags should identify one or more subnets | `map(string)` | n/a | yes |
6767
| <a name="input_tags"></a> [tags](#input\_tags) | Common and mandatory tags for the resources | `map(string)` | n/a | yes |
6868
| <a name="input_vpc_tags"></a> [vpc\_tags](#input\_vpc\_tags) | Tags to discover target VPC, these tags should uniquely identify a VPC | `map(string)` | n/a | yes |
69-
| <a name="input_efs_access_point_specs"></a> [efs\_access\_point\_specs](#input\_efs\_access\_point\_specs) | List of EFS Access Point Specs to be created. It can be empty list. | <pre>list(object({<br> efs_name = string # unique name e.g. common<br> efs_ap = string # unique name e.g. common_sftp<br> uid = number<br> gid = number<br> root_path = string # e.g. /{env}/{project}/{purpose}/{name}<br> owner_uid = number # e.g. 0<br> owner_gid = number # e.g. 0<br> root_permission = string # e.g. 0755<br> }))</pre> | `[]` | no |
69+
| <a name="input_efs_access_point_specs"></a> [efs\_access\_point\_specs](#input\_efs\_access\_point\_specs) | List of EFS Access Point Specs to be created. It can be empty list. | <pre>list(object({<br> efs_name = string # unique name e.g. common<br> efs_ap = string # unique name e.g. common_sftp<br> uid = number<br> gid = number<br> secondary_gids = list(number)<br> root_path = string # e.g. /{env}/{project}/{purpose}/{name}<br> owner_uid = number # e.g. 0<br> owner_gid = number # e.g. 0<br> root_permission = string # e.g. 0755<br> principal_arns = list(string)<br> }))</pre> | `[]` | no |
7070
| <a name="input_efs_id"></a> [efs\_id](#input\_efs\_id) | EFS File System Id, if not provided a new EFS will be created | `string` | `null` | no |
7171
| <a name="input_kms_alias"></a> [kms\_alias](#input\_kms\_alias) | KMS Alias to discover KMS for EFS encryption, if not provided a new CMK will be created | `string` | `""` | no |
7272
| <a name="input_security_group_tags"></a> [security\_group\_tags](#input\_security\_group\_tags) | Tags used to discover EFS Security Group, if not provided new EFS security group will be created | `map(string)` | `null` | no |

examples/efs/scenario2/main.tf

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module "common_efs" {
2-
source = "../../../modules/aws/efs"
2+
source = "github.com/aws-samples/aws-tf-efs//modules/aws/efs?ref=v1.0.0"
33

44
region = var.region
55

@@ -14,18 +14,18 @@ module "common_efs" {
1414
kms_alias = var.kms_alias
1515
kms_admin_roles = ["Admin"]
1616

17-
efs_specs = [
18-
{
19-
name = "common"
20-
efs_id = var.efs_id
21-
encrypted = true
22-
performance_mode = "generalPurpose"
23-
transition_to_ia = "AFTER_7_DAYS"
24-
backup_plan = "EVERY-DAY"
25-
# If security_group_tags is null, EFS security group is created
26-
security_group_tags = var.security_group_tags
27-
}
28-
]
17+
# If security_group_tags is null, EFS security group is created
18+
security_group_tags = var.security_group_tags
19+
20+
efs_name = "common"
21+
efs_id = var.efs_id
22+
encrypted = true
23+
performance_mode = "generalPurpose"
24+
transition_to_ia = "AFTER_7_DAYS"
25+
26+
efs_tags = {
27+
"BackupPlan" = "EVERY-DAY"
28+
}
2929

3030
efs_access_point_specs = var.efs_access_point_specs
3131
}

examples/efs/scenario2/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ output "efs_ap" {
1010

1111
output "efs_kms" {
1212
description = "KMS Keys created for EFS"
13-
value = module.common_efs.efs_kms
13+
value = module.common_efs.efs_kms_aliases
1414
}

examples/efs/scenario2/terraform.tfvars

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ region = "us-east-1"
66
/*---------------------------------------------------------
77
Common Variables
88
---------------------------------------------------------*/
9-
project = "scenario2-efs"
9+
project = "scenario2-efs-sftp"
1010
env_name = "dev"
1111
tags = {
1212
Env = "DEV"
13-
Project = "scenario2-efs"
13+
Project = "scenario2-efs-sftp"
1414
}
1515

1616
/*---------------------------------------------------------

examples/efs/scenario2/variables.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ variable "efs_access_point_specs" {
6565
efs_ap = string # unique name e.g. common_sftp
6666
uid = number
6767
gid = number
68+
secondary_gids = list(number)
6869
root_path = string # e.g. /{env}/{project}/{purpose}/{name}
6970
owner_uid = number # e.g. 0
7071
owner_gid = number # e.g. 0
7172
root_permission = string # e.g. 0755
73+
principal_arns = list(string)
7274
}))
7375
default = []
7476
}

examples/sftp/scenario1/.terraform.lock.hcl

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/sftp/scenario1/terraform.tfvars

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ efs_id = "your-efs-id"
5252
efs_ap_id = "your-efs-ap-id"
5353
# Use existing EFS SG
5454
efs_sg_tags = {
55-
Name = "scenario1-efs-common-efs-sg"
55+
Name = "scenario1-efs-sftp-common-efs-sg"
5656
Env = "DEV"
5757
}
5858

5959
#efs exists, so kms must exist
60-
efs_kms_alias = "alias/scenario1-efs/efs"
60+
efs_kms_alias = "alias/scenario1-efs-sftp/efs"
6161

6262
#create new roles
6363
user_role = null

examples/sftp/scenario2/.terraform.lock.hcl

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)