Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
terraform-aws-wdps-eks
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Terraform Modules
terraform-aws-wdps-eks
Commits
8e508daa
Commit
8e508daa
authored
Oct 10, 2021
by
Jose Ernesto Suarez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the ingrss config and the k8s base
parent
88b8b379
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
173 additions
and
0 deletions
+173
-0
ingress.tf
ingress.tf
+51
-0
k8s-base.tf
k8s-base.tf
+48
-0
locals.tf
locals.tf
+35
-0
variables.tf
variables.tf
+39
-0
No files found.
ingress.tf
0 → 100644
View file @
8e508daa
resource
"kubernetes_ingress"
"ingress"
{
for_each
=
local
.
ingresses
metadata
{
name
=
each
.
key
namespace
=
lookup
(
each
.
value
,
"namespace"
,
"default"
)
annotations
=
{
"kubernetes.io/ingress.class"
=
"nginx"
"cert-manager.io/cluster-issuer"
=
"letsencrypt-production"
}
}
spec
{
dynamic
"rule"
{
for_each
=
each
.
value
[
"hosts"
]
content
{
host
=
rule
.
value
.
name
http
{
dynamic
"path"
{
for_each
=
rule
.
value
.
rules
content
{
path
=
path
.
value
.
path
backend
{
service_name
=
path
.
value
.
service_name
service_port
=
path
.
value
.
service_port
}
}
}
}
}
}
dynamic
"tls"
{
for_each
=
lookup
(
each
.
value
,
"tls_secret_name"
,
""
)
!
=
""
?
[
[
for
h
in
each
.
value
[
"hosts"
]
:
h
.
name
]
]
:
[]
content
{
secret_name
=
each
.
value
[
"tls_secret_name"
]
hosts
=
tls
.
value
}
}
}
}
k8s-base.tf
0 → 100644
View file @
8e508daa
# create our namespaces
resource
"kubernetes_namespace"
"managed"
{
for_each
=
toset
(
var
.
managed_namespaces
)
metadata
{
name
=
each
.
value
labels
=
{
"app.kubernetes.io/managed-by"
=
"Terraform"
}
}
}
# create managed secrets
resource
"kubernetes_secret"
"managed"
{
for_each
=
local
.
secrets_map
metadata
{
name
=
each
.
key
namespace
=
each
.
value
[
"namespace"
]
labels
=
{
"app.kubernetes.io/managed-by"
=
"Terraform"
}
}
type
=
each
.
value
[
"secret_type"
]
data
=
each
.
value
[
"data"
]
depends_on
=
[
kubernetes_namespace
.
managed
]
}
# create managed config maps
resource
"kubernetes_config_map"
"managed"
{
for_each
=
local
.
configs_map
metadata
{
name
=
each
.
key
namespace
=
each
.
value
[
"namespace"
]
labels
=
{
"app.kubernetes.io/managed-by"
=
"Terraform"
}
}
data
=
each
.
value
[
"data"
]
binary_data
=
lookup
(
each
.
value
,
"binary_data"
,
null
)
depends_on
=
[
kubernetes_namespace
.
managed
]
}
locals.tf
0 → 100644
View file @
8e508daa
##########
# K8S-BASE
##########
# prepare our configs
locals
{
secrets
=
flatten
(
[
for
n
,
d
in
var
.
settings
:
[
for
s
,
dat
in
lookup
(
d
,
"secrets"
,
{}
)
:
merge
(
{
secret_name
=
s
namespace
=
n
secret_type
=
"Opaque"
data
=
null
},
dat
)
]]
)
secrets_map
=
{
for
item
in
local
.
secrets
:
item
.
secret_name
=
>
item
}
configmaps
=
flatten
(
[
for
n
,
d
in
var
.
settings
:
[
for
c
,
dat
in
lookup
(
d
,
"configmaps"
,
{}
)
:
merge
(
{
config_name
=
c
namespace
=
n
data
=
null
},
dat
)
]]
)
configs_map
=
{
for
item
in
local
.
configmaps
:
item
.
config_name
=
>
item
}
}
##########
# K8S-BASE INGRESS
##########
locals
{
ingresses
=
{
for
k
,
v
in
var
.
ingresses
:
v
[
"name"
]
=
>
v
}
}
variables.tf
View file @
8e508daa
...
...
@@ -80,3 +80,42 @@ variable "map_accounts" {
type
=
list
(
string
)
default
=
[]
}
##########
# K8S-BASE
##########
variable
"settings"
{
description
=
"The map of namespaces, their secrets and configmaps"
type
=
any
# should look like:
# {
# namespace-name = {
# secrets = {
# my-secret-name = {
# secret_type = "Opaque"
# data = { ... } # any type of data you want to put in
# }
# configs = {
# my-config-name = {
# data = { ... } # any type of data you want to put in
# binary_data = { ... } # this field only accepts base64-encoded payloads
# }
# }
# }
# }
default
=
{}
}
variable
"managed_namespaces"
{
description
=
"List of namespaces managed by Terraform"
type
=
list
(
string
)
default
=
[]
}
##########
# K8S-BASE INGRESS
##########
variable
"ingresses"
{
description
=
"List of the ingresses with rules"
type
=
any
default
=
[]
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment