Skip to content

Commit 2a6830d

Browse files
committed
feat: update name and use for_each function in code
1 parent 8d97acb commit 2a6830d

File tree

4 files changed

+226
-33
lines changed

4 files changed

+226
-33
lines changed

.gitignore

Lines changed: 205 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,210 @@
11
# ignored files
2+
*~
3+
4+
# temporary files which can be created if a process still has a handle open of a deleted file
5+
.fuse_hidden*
6+
7+
# KDE directory preferences
8+
.directory
9+
10+
# Linux trash folder which might appear on any partition or disk
11+
.Trash-*
12+
13+
# .nfs files are created when an open file is removed but is still being accessed
14+
.nfs*
15+
### Eclipse template
16+
17+
.metadata
18+
bin/
19+
tmp/
20+
*.tmp
21+
*.bak
22+
*.swp
23+
*~.nib
24+
local.properties
25+
.settings/
26+
.loadpath
27+
.recommenders
28+
29+
# External tool builders
30+
.externalToolBuilders/
31+
32+
# Locally stored "Eclipse launch configurations"
33+
*.launch
34+
35+
# PyDev specific (Python IDE for Eclipse)
36+
*.pydevproject
37+
38+
# CDT-specific (C/C++ Development Tooling)
39+
.cproject
40+
41+
# Java annotation processor (APT)
42+
.factorypath
43+
44+
# PDT-specific (PHP Development Tools)
45+
.buildpath
46+
47+
# sbteclipse plugin
48+
.target
49+
50+
# Tern plugin
51+
.tern-project
52+
53+
# TeXlipse plugin
54+
.texlipse
55+
56+
# STS (Spring Tool Suite)
57+
.springBeans
58+
59+
# Code Recommenders
60+
.recommenders/
61+
62+
# Scala IDE specific (Scala & Java development for Eclipse)
63+
.cache-main
64+
.scala_dependencies
65+
.worksheet
66+
### Windows template
67+
# Windows thumbnail cache files
68+
Thumbs.db
69+
ehthumbs.db
70+
ehthumbs_vista.db
71+
72+
# Dump file
73+
*.stackdump
74+
75+
# Folder config file
76+
[Dd]esktop.ini
77+
78+
# Recycle Bin used on file shares
79+
$RECYCLE.BIN/
80+
81+
# Windows Installer files
82+
*.cab
83+
*.msi
84+
*.msm
85+
*.msp
86+
87+
# Windows shortcuts
88+
*.lnk
89+
### Ansible template
90+
*.retry
91+
### macOS template
92+
# General
93+
.DS_Store
94+
.AppleDouble
95+
.LSOverride
96+
97+
# Icon must end with two \r
98+
Icon
99+
100+
# Thumbnails
101+
._*
102+
103+
# Files that might appear in the root of a volume
104+
.DocumentRevisions-V100
105+
.fseventsd
106+
.Spotlight-V100
107+
.TemporaryItems
108+
.Trashes
109+
.VolumeIcon.icns
110+
.com.apple.timemachine.donotpresent
111+
112+
# Directories potentially created on remote AFP share
113+
.AppleDB
114+
.AppleDesktop
115+
Network Trash Folder
116+
Temporary Items
117+
.apdisk
118+
### Archives template
119+
# It's better to unpack these files and commit the raw source because
120+
# git has its own built in compression methods.
121+
*.7z
122+
*.jar
123+
*.rar
124+
*.zip
125+
*.gz
126+
*.tgz
127+
*.bzip
128+
*.bz2
129+
*.xz
130+
*.lzma
131+
*.cab
132+
133+
# Packing-only formats
134+
*.iso
135+
*.tar
136+
137+
# Package management formats
138+
*.dmg
139+
*.xpi
140+
*.gem
141+
*.egg
142+
*.deb
143+
*.rpm
144+
*.msi
145+
*.msm
146+
*.msp
147+
### JetBrains template
148+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
149+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
150+
151+
/.idea/
152+
# User-specific stuff:
153+
.idea/**/workspace.xml
154+
.idea/**/tasks.xml
155+
.idea/dictionaries
156+
157+
# Sensitive or high-churn files:
158+
.idea/**/dataSources/
159+
.idea/**/dataSources.ids
160+
.idea/**/dataSources.xml
161+
.idea/**/dataSources.local.xml
162+
.idea/**/sqlDataSources.xml
163+
.idea/**/dynamic.xml
164+
.idea/**/uiDesigner.xml
165+
166+
# Gradle:
167+
.idea/**/gradle.xml
168+
.idea/**/libraries
169+
170+
# CMake
171+
cmake-build-debug/
172+
173+
# Mongo Explorer plugin:
174+
.idea/**/mongoSettings.xml
175+
176+
## File-based project format:
177+
*.iws
178+
179+
## Plugin-specific files:
180+
181+
# IntelliJ
182+
out/
183+
184+
# mpeltonen/sbt-idea plugin
185+
.idea_modules/
186+
# User-specific stuff:
187+
.idea/*
188+
# JIRA plugin
189+
atlassian-ide-plugin.xml
190+
191+
# Cursive Clojure plugin
192+
.idea/replstate.xml
193+
194+
# TFstste
195+
*.tfstate*
196+
197+
deployment/_logs/ansible-log.json
198+
deployment/_logs/ansible-log.log
199+
deployment/_logs/facts/*
200+
deployment/_logs/retry/*
201+
_app/*
202+
ansible-log.json
203+
.terraform
204+
terraform.tfstate
205+
2206
*.tfstate
3207
*.tfstate.backup
4-
.terraform
5-
.idea
6208
*.iml
7209
*.terraform.lock.hcl
8-
/_test/go.mod
9-
/_test/go.sum
210+
*.lock.hcl

_example/public/example.tf

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@ provider "aws" {
88

99
module "s3_bucket" {
1010
source = "clouddrove/s3/aws"
11-
version = "1.3.0"
11+
version = "2.0.0"
1212

1313
name = "clouddrove-sftp-bucket01"
1414
environment = "test"
1515
label_order = ["environment", "name"]
1616

17-
versioning = true
18-
logging = true
19-
acl = "private"
20-
force_destroy = true
17+
versioning = true
18+
logging = false
19+
acl = "private"
2120
}
2221

2322
################################################################################

_example/vpc/example.tf

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ module "vpc" {
1414
cidr_block = "10.0.0.0/16"
1515
enable_flow_log = true # Flow logs will be stored in cloudwatch log group. Variables passed in default.
1616
create_flow_log_cloudwatch_iam_role = true
17-
additional_cidr_block = ["172.3.0.0/16", "172.2.0.0/16"]
18-
dhcp_options_domain_name = "service.consul"
19-
dhcp_options_domain_name_servers = ["127.0.0.1", "10.10.0.2"]
2017
}
2118

2219
################################################################################
@@ -25,21 +22,20 @@ module "vpc" {
2522

2623
module "subnets" {
2724
source = "clouddrove/subnet/aws"
28-
version = "1.0.1"
29-
30-
name = "subnets"
31-
environment = "test"
32-
label_order = ["environment", "name"]
33-
# tags = local.tags
34-
enabled = true
25+
version = "2.0.1"
3526

3627
nat_gateway_enabled = true
3728
single_nat_gateway = true
29+
name = "subnets"
30+
environment = "test"
31+
label_order = ["environment", "name"]
3832
availability_zones = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
3933
vpc_id = module.vpc.vpc_id
34+
type = "public-private"
35+
igw_id = module.vpc.igw_id
4036
cidr_block = module.vpc.vpc_cidr_block
4137
ipv6_cidr_block = module.vpc.ipv6_cidr_block
42-
type = "public-private"
38+
enable_ipv6 = false
4339
}
4440

4541
################################################################################
@@ -97,16 +93,13 @@ module "security_group_sftp" {
9793

9894
module "s3_bucket" {
9995
source = "clouddrove/s3/aws"
100-
version = "1.3.0"
96+
version = "2.0.0"
10197

10298
name = "clouddrove-sftp-bucket"
10399
environment = "test"
104100
label_order = ["environment", "name"]
105-
106-
versioning = true
107-
logging = true
108-
acl = "private"
109-
force_destroy = true
101+
versioning = true
102+
acl = "private"
110103
}
111104

112105
################################################################################

main.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,15 @@ data "aws_iam_policy_document" "assume_role_policy" {
128128
resource "aws_iam_role" "s3_access_for_sftp_users" {
129129
for_each = var.enabled ? local.user_names_map : {}
130130

131-
name = module.labels.id
131+
name = format("%s-sftp-users", module.labels.id)
132132
assume_role_policy = join("", data.aws_iam_policy_document.assume_role_policy[*].json)
133133
managed_policy_arns = [aws_iam_policy.s3_access_for_sftp_users[each.value.user_name].arn]
134134
}
135135

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

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

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

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

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

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

@@ -240,10 +240,10 @@ resource "aws_transfer_user" "transfer_server_user" {
240240
##----------------------------------------------------------------------------------
241241

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

249249

0 commit comments

Comments
 (0)