diff --git a/INDEX.md b/INDEX.md index 88021edf..d783cec7 100644 --- a/INDEX.md +++ b/INDEX.md @@ -9,6 +9,7 @@ | `aws_dynamodb_table` | [aws](aws/aws_dynamodb_table)

[simple](aws/aws_dynamodb_table/simple) | | `aws_ebs_volume` | [aws](aws/aws_ebs_volume)

[simple](aws/aws_ebs_volume/simple)

[volume_attachment](aws/aws_ebs_volume/volume_attachment)

[ebs_snapshot](aws/aws_ebs_volume/ebs_snapshot) | | `aws_eks` | [aws, spot_and_fargate](aws/aws_eks/fargate/spot_and_fargate) | +| `aws_efs` | [aws](aws/aws_efs)

[simple](aws/aws_efs/simple) | | `aws_elb` | [aws](aws/aws_elb)

[application_elb](aws/aws_elb/application_elb)

[network_elb](aws/aws_elb/network_elb) [classic_elb](aws/aws_elb/classic_elb) | | `aws_iam` | [iam_user_and_access_key](aws/aws_iam/users)

[users_and_groups](aws/aws_iam/groups) | | `aws_instance` | [aws](aws/aws_instance)

[simple](aws/aws_instance/simple)

[simple_ssh_access](aws/aws_instance/simple_ssh_access)

[ami_lookup](aws/aws_instance/ami_lookup) | diff --git a/aws/aws_efs/simple/destroy.sh b/aws/aws_efs/simple/destroy.sh new file mode 100755 index 00000000..0f65744a --- /dev/null +++ b/aws/aws_efs/simple/destroy.sh @@ -0,0 +1,2 @@ +#!/bin/bash +../../../bin/destroy.sh aws diff --git a/aws/aws_efs/simple/main.tf b/aws/aws_efs/simple/main.tf new file mode 100644 index 00000000..04557500 --- /dev/null +++ b/aws/aws_efs/simple/main.tf @@ -0,0 +1,76 @@ + +# Summary: Create an EFS in AWS + +# Documentation: https://www.terraform.io/docs/language/settings/index.html +terraform { + required_version = ">= 1.0.0" + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 3.38" + } + } +} + +# Documentation: https://www.terraform.io/docs/language/providers/requirements.html +provider "aws" { + region = "us-east-1" + default_tags { + tags = { + cs_terraform_examples = "aws_efs/simple" + } + } +} + +# Documentation: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc +data "aws_vpc" "changeme_default_aws_vpc" { + default = true +} + +# Documentation: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet_ids +data "aws_subnet_ids" "changeme_aws_subnet_ids" { + vpc_id = data.aws_vpc.changeme_default_aws_vpc.id +} + +# Documentation: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group +resource "aws_security_group" "changeme_efs_aws_security_group" { + name = "changeme-simple-efs-security-group" + description = "Allow inbound traffic" + ingress { + from_port = 2049 + to_port = 2049 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["0.0.0.0/0"] + } +} + +# Documentation: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/efs_file_system +resource "aws_efs_file_system" "changeme_aws_efs" { + performance_mode = "generalPurpose" + throughput_mode = "bursting" + encrypted = "false" + kms_key_id = null + + tags = { + Name = "changeme-simple-efs" + } + + lifecycle_policy { + transition_to_ia = "AFTER_30_DAYS" + } +} + +# Documentation: https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/efs_mount_target +resource "aws_efs_mount_target" "changeme_efs_mount_target" { + for_each = data.aws_subnet_ids.changeme_aws_subnet_ids.ids + subnet_id = each.value + file_system_id = aws_efs_file_system.changeme_aws_efs.id + security_groups = [aws_security_group.changeme_efs_aws_security_group.id] +} diff --git a/aws/aws_efs/simple/run.sh b/aws/aws_efs/simple/run.sh new file mode 100755 index 00000000..b84d2277 --- /dev/null +++ b/aws/aws_efs/simple/run.sh @@ -0,0 +1,2 @@ +#!/bin/bash +../../../bin/apply.sh aws