Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
209 changes: 205 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,210 @@
# ignored files
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### Eclipse template

.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# PyDev specific (Python IDE for Eclipse)
*.pydevproject

# CDT-specific (C/C++ Development Tooling)
.cproject

# Java annotation processor (APT)
.factorypath

# PDT-specific (PHP Development Tools)
.buildpath

# sbteclipse plugin
.target

# Tern plugin
.tern-project

# TeXlipse plugin
.texlipse

# STS (Spring Tool Suite)
.springBeans

# Code Recommenders
.recommenders/

# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
### Windows template
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk
### Ansible template
*.retry
### macOS template
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Archives template
# It's better to unpack these files and commit the raw source because
# git has its own built in compression methods.
*.7z
*.jar
*.rar
*.zip
*.gz
*.tgz
*.bzip
*.bz2
*.xz
*.lzma
*.cab

# Packing-only formats
*.iso
*.tar

# Package management formats
*.dmg
*.xpi
*.gem
*.egg
*.deb
*.rpm
*.msi
*.msm
*.msp
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

/.idea/
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries

# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle:
.idea/**/gradle.xml
.idea/**/libraries

# CMake
cmake-build-debug/

# Mongo Explorer plugin:
.idea/**/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/
# User-specific stuff:
.idea/*
# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# TFstste
*.tfstate*

deployment/_logs/ansible-log.json
deployment/_logs/ansible-log.log
deployment/_logs/facts/*
deployment/_logs/retry/*
_app/*
ansible-log.json
.terraform
terraform.tfstate

*.tfstate
*.tfstate.backup
.terraform
.idea
*.iml
*.terraform.lock.hcl
/_test/go.mod
/_test/go.sum
*.lock.hcl
9 changes: 4 additions & 5 deletions _example/public/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ provider "aws" {

module "s3_bucket" {
source = "clouddrove/s3/aws"
version = "1.3.0"
version = "2.0.0"

name = "clouddrove-sftp-bucket01"
environment = "test"
label_order = ["environment", "name"]

versioning = true
logging = true
acl = "private"
force_destroy = true
versioning = true
logging = false
acl = "private"
}

################################################################################
Expand Down
27 changes: 10 additions & 17 deletions _example/vpc/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ module "vpc" {
cidr_block = "10.0.0.0/16"
enable_flow_log = true # Flow logs will be stored in cloudwatch log group. Variables passed in default.
create_flow_log_cloudwatch_iam_role = true
additional_cidr_block = ["172.3.0.0/16", "172.2.0.0/16"]
dhcp_options_domain_name = "service.consul"
dhcp_options_domain_name_servers = ["127.0.0.1", "10.10.0.2"]
}

################################################################################
Expand All @@ -25,21 +22,20 @@ module "vpc" {

module "subnets" {
source = "clouddrove/subnet/aws"
version = "1.0.1"

name = "subnets"
environment = "test"
label_order = ["environment", "name"]
# tags = local.tags
enabled = true
version = "2.0.1"

nat_gateway_enabled = true
single_nat_gateway = true
name = "subnets"
environment = "test"
label_order = ["environment", "name"]
availability_zones = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
vpc_id = module.vpc.vpc_id
type = "public-private"
igw_id = module.vpc.igw_id
cidr_block = module.vpc.vpc_cidr_block
ipv6_cidr_block = module.vpc.ipv6_cidr_block
type = "public-private"
enable_ipv6 = false
}

################################################################################
Expand Down Expand Up @@ -97,16 +93,13 @@ module "security_group_sftp" {

module "s3_bucket" {
source = "clouddrove/s3/aws"
version = "1.3.0"
version = "2.0.0"

name = "clouddrove-sftp-bucket"
environment = "test"
label_order = ["environment", "name"]

versioning = true
logging = true
acl = "private"
force_destroy = true
versioning = true
acl = "private"
}

################################################################################
Expand Down
14 changes: 7 additions & 7 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,15 @@ data "aws_iam_policy_document" "assume_role_policy" {
resource "aws_iam_role" "s3_access_for_sftp_users" {
for_each = var.enabled ? local.user_names_map : {}

name = module.labels.id
name = format("%s-sftp-users", module.labels.id)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think uou will get errors if more then one user will be defined for sftp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evgenyidf Hello
Yes, I have done it using for_each function. Now such error will not occur

assume_role_policy = join("", data.aws_iam_policy_document.assume_role_policy[*].json)
managed_policy_arns = [aws_iam_policy.s3_access_for_sftp_users[each.value.user_name].arn]
}

resource "aws_iam_policy" "s3_access_for_sftp_users" {
for_each = var.enabled ? local.user_names_map : {}

name = module.labels.id
name = format("%s-sftp-users", module.labels.id)
policy = data.aws_iam_policy_document.s3_access_for_sftp_users[each.value.user_name].json

tags = module.labels.tags
Expand All @@ -149,7 +149,7 @@ resource "aws_iam_policy" "s3_access_for_sftp_users" {
resource "aws_iam_policy" "logging" {
count = var.enabled ? 1 : 0

name = module.labels.id
name = format("%s-logging", module.labels.id)
policy = join("", data.aws_iam_policy_document.logging[*].json)

tags = module.labels.tags
Expand All @@ -158,7 +158,7 @@ resource "aws_iam_policy" "logging" {
resource "aws_iam_role" "logging" {
count = var.enabled ? 1 : 0

name = module.labels.id
name = format("%s-logging", module.labels.id)
assume_role_policy = join("", data.aws_iam_policy_document.assume_role_policy[*].json)
managed_policy_arns = [join("", aws_iam_policy.logging[*].arn)]

Expand Down Expand Up @@ -240,10 +240,10 @@ resource "aws_transfer_user" "transfer_server_user" {
##----------------------------------------------------------------------------------

resource "aws_transfer_ssh_key" "transfer_server_ssh_key" {
count = var.enabled ? length(var.sftp_users) : 0
for_each = var.enabled ? var.sftp_users : {}
server_id = join("", aws_transfer_server.transfer_server[*].id)
user_name = aws_transfer_user.transfer_server_user[count.index].user_name
body = aws_transfer_user.transfer_server_user[count.index].public_key
user_name = var.sftp_users[each.key].user_name
body = var.sftp_users[each.key].public_key
}


Expand Down