Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions INDEX.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
| `aws_dynamodb_table` | [aws](aws/aws_dynamodb_table) <p/> [simple](aws/aws_dynamodb_table/simple) |
| `aws_ebs_volume` | [aws](aws/aws_ebs_volume) <p/>[simple](aws/aws_ebs_volume/simple) <p/> [volume_attachment](aws/aws_ebs_volume/volume_attachment) <p/> [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) <p/> [simple](aws/aws_efs/simple) |
| `aws_elb` | [aws](aws/aws_elb) <p/> [application_elb](aws/aws_elb/application_elb) <p/> [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) <p/>[users_and_groups](aws/aws_iam/groups) |
| `aws_instance` | [aws](aws/aws_instance) <p/> [simple](aws/aws_instance/simple) <p/> [simple_ssh_access](aws/aws_instance/simple_ssh_access) <p/> [ami_lookup](aws/aws_instance/ami_lookup) |
Expand Down
2 changes: 2 additions & 0 deletions aws/aws_efs/simple/destroy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
../../../bin/destroy.sh aws
76 changes: 76 additions & 0 deletions aws/aws_efs/simple/main.tf
Original file line number Diff line number Diff line change
@@ -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]
}
2 changes: 2 additions & 0 deletions aws/aws_efs/simple/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
../../../bin/apply.sh aws