-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Staging Lets Encrypt Certificates working 🎉🎉🎉 (#10)
- Loading branch information
1 parent
d82ea7d
commit 46b1c5f
Showing
16 changed files
with
512 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
name: gke-test-2 | ||
project: root-territory-384205 | ||
# Project configuration | ||
name: gke-test-3 | ||
domain: gke-test-3.coilysiren.me | ||
zone: coilysiren.me # domain - name = zone | ||
email: [email protected] | ||
|
||
# Google Cloud Platform configuration | ||
project: dotted-hope-405813 | ||
statebucket: coilysiren-k8s-gpc-tfstate-3 | ||
region: us-central1 | ||
|
||
# https://github.com/cert-manager/cert-manager/releases | ||
cert-manager-version: v1.13.2 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,88 @@ | ||
locals { | ||
name = yamldecode(file("../../config.yml")).name | ||
zone = yamldecode(file("../../config.yml")).zone | ||
domain = yamldecode(file("../../config.yml")).domain | ||
email = yamldecode(file("../../config.yml")).email | ||
} | ||
|
||
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/client_config | ||
data "google_client_config" "default" {} | ||
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user | ||
resource "aws_iam_user" "user" { | ||
name = "certbot" | ||
} | ||
|
||
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key | ||
resource "aws_iam_access_key" "key" { | ||
user = aws_iam_user.user.name | ||
} | ||
|
||
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy | ||
resource "aws_iam_policy" "policy" { | ||
name = "certbot" | ||
|
||
# https://cert-manager.io/docs/configuration/acme/dns01/route53/ | ||
policy = jsonencode({ | ||
Version = "2012-10-17" | ||
Statement = [ | ||
{ | ||
Effect = "Allow", | ||
Action = "route53:ChangeResourceRecordSets", | ||
Resource = data.aws_route53_zone.zone.arn, | ||
}, | ||
{ | ||
Effect = "Allow" | ||
Action = [ | ||
"route53:Get*", | ||
"route53:List*", | ||
] | ||
Resource = "*" | ||
}, | ||
] | ||
}) | ||
} | ||
|
||
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_user_policy_attachment | ||
resource "aws_iam_user_policy_attachment" "test-attach" { | ||
user = aws_iam_user.user.name | ||
policy_arn = aws_iam_policy.policy.arn | ||
} | ||
|
||
data "kubernetes_service" "service" { | ||
# https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/secret | ||
resource "kubernetes_secret" "secret" { | ||
metadata { | ||
name = "application" | ||
name = "route53-credentials-secret" | ||
} | ||
|
||
data = { | ||
"access-key-id" = aws_iam_access_key.key.id | ||
"secret-access-key" = aws_iam_access_key.key.secret | ||
} | ||
} | ||
|
||
# https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/secret | ||
resource "kubernetes_secret" "cert" { | ||
metadata { | ||
name = "web-ssl" | ||
} | ||
type = "kubernetes.io/tls" | ||
data = { | ||
"tls.crt" = "" | ||
"tls.key" = "" | ||
} | ||
lifecycle { | ||
ignore_changes = [ | ||
metadata, | ||
data, | ||
] | ||
} | ||
} | ||
|
||
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/route53_zone | ||
data "aws_route53_zone" "zone" { | ||
name = "coilysiren.me." | ||
name = "${local.zone}." | ||
private_zone = false | ||
} | ||
|
||
# https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record | ||
resource "aws_route53_record" "record" { | ||
zone_id = data.aws_route53_zone.zone.zone_id | ||
name = "${local.name}.coilysiren.me." | ||
type = "A" | ||
ttl = "300" | ||
records = [data.kubernetes_service.service.status.0.load_balancer.0.ingress.0.ip] | ||
# https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_address | ||
resource "google_compute_address" "address" { | ||
name = "application-ingress" | ||
address_type = "EXTERNAL" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
apiVersion: v1 | ||
items: | ||
- apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
annotations: | ||
cloud.google.com/neg: '{"ingress": true}' | ||
name: application | ||
spec: | ||
ports: | ||
- name: http | ||
port: 80 | ||
targetPort: 8080 | ||
selector: | ||
app: application | ||
type: ClusterIP | ||
- apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: application | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: application | ||
template: | ||
metadata: | ||
labels: | ||
app: application | ||
spec: | ||
containers: | ||
- image: us-central1-docker.pkg.dev/dotted-hope-405813/repository/gke-test-3:certs-add8cea-kai | ||
name: application | ||
ports: | ||
- containerPort: 8080 | ||
kind: List | ||
metadata: | ||
resourceVersion: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.