Skip to content

Commit 52c53cc

Browse files
committed
add DNS code
1 parent 32fa615 commit 52c53cc

File tree

10 files changed

+191
-429
lines changed

10 files changed

+191
-429
lines changed

.werft/installer-tests.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ const INFRA_PHASES: { [name: string]: InfraConfig } = {
214214
},
215215
DESTROY: {
216216
phase: "destroy",
217-
makeTarget: "cleanup",
217+
makeTarget: `cleanup cloud=${cloud}`,
218218
description: "Destroy the created infrastucture",
219219
},
220220
RESULTS: {
@@ -279,7 +279,10 @@ function cleanup() {
279279
const phase = "destroy-infrastructure";
280280
werft.phase(phase, "Destroying all the created resources");
281281

282-
const response = exec(`make -C ${makefilePath} cleanup`, { slice: "run-terrafrom-destroy", dontCheckRc: true });
282+
const response = exec(`make -C ${makefilePath} cleanup cloud=${cloud}`, {
283+
slice: "run-terrafrom-destroy",
284+
dontCheckRc: true,
285+
});
283286

284287
// if the destroy command fail, we check if any resources are pending to be removed
285288
// if nothing is yet to be cleaned, we return with success

install/infra/terraform/aks/output.tf

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,32 @@ output "external_dns_secrets" {
3636
}
3737

3838
output "external_dns_settings" {
39-
value = {
40-
provider = "azure"
41-
"azure.resourceGroup" = azurerm_resource_group.gitpod.name
42-
"azure.subscriptionId" = data.azurerm_client_config.current.subscription_id
43-
"azure.tenantId" = data.azurerm_client_config.current.tenant_id
44-
"azure.useManagedIdentityExtension" = true
45-
"azure.userAssignedIdentityID" = azurerm_kubernetes_cluster.k8s.kubelet_identity.0.client_id
46-
}
39+
value = [
40+
{
41+
"name": "provider",
42+
"value": "azure"
43+
},
44+
{
45+
"name": "azure.resourceGroup",
46+
"value": azurerm_resource_group.gitpod.name,
47+
},
48+
{
49+
"name": "azure.subscriptionId",
50+
"value": data.azurerm_client_config.current.subscription_id,
51+
},
52+
{
53+
"name": "azure.tenantId",
54+
"value": data.azurerm_client_config.current.tenant_id,
55+
},
56+
{
57+
"name": "azure.useManagedIdentityExtension",
58+
"value": true
59+
},
60+
{
61+
"name": "azure.userAssignedIdentityID",
62+
"value": azurerm_kubernetes_cluster.k8s.kubelet_identity.0.client_id
63+
},
64+
]
4765
}
4866

4967
output "k8s_connection" {

install/infra/terraform/eks/dns.tf

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
variable "domain_name" {}
2+
variable "cluster_name" {}
3+
4+
terraform {
5+
required_providers {
6+
aws = {
7+
version = " ~> 3.0"
8+
source = "registry.terraform.io/hashicorp/aws"
9+
}
10+
}
11+
}
12+
13+
provider "aws" {
14+
region = "eu-west-1"
15+
}
16+
17+
resource "aws_route53_zone" "gitpod" {
18+
name = var.domain_name
19+
20+
tags = {
21+
Environment = "test"
22+
}
23+
}
24+
25+
resource "aws_iam_policy" "gitpod" {
26+
name = "role-${var.cluster_name}"
27+
28+
# Terraform's "jsonencode" function converts a
29+
# Terraform expression result to valid JSON syntax.
30+
policy = jsonencode({
31+
Version = "2012-10-17",
32+
Statement = [
33+
{
34+
Effect = "Allow",
35+
Action = [
36+
"route53:ChangeResourceRecordSets"
37+
],
38+
Resource = [
39+
"arn:aws:route53:::hostedzone/*"
40+
]
41+
},
42+
{
43+
Effect = "Allow",
44+
Action = [
45+
"route53:ListHostedZones",
46+
"route53:ListResourceRecordSets"
47+
],
48+
Resource = [ "*" ]
49+
}
50+
],
51+
})
52+
}
53+
54+
resource "aws_iam_role" "gitpod" {
55+
name = "iam-route53-${var.cluster_name}"
56+
57+
assume_role_policy = <<POLICY
58+
{
59+
"Version": "2012-10-17",
60+
"Statement": [
61+
{
62+
"Effect": "Allow",
63+
"Principal": {
64+
"Service": "ec2.amazonaws.com"
65+
},
66+
"Action": "sts:AssumeRole"
67+
}
68+
]
69+
}
70+
POLICY
71+
}
72+
73+
resource "aws_iam_role_policy_attachment" "route53" {
74+
policy_arn = resource.aws_iam_policy.gitpod.arn
75+
role = aws_iam_role.gitpod.name
76+
}

install/infra/terraform/eks/kubernetes.tf

Lines changed: 0 additions & 203 deletions
This file was deleted.

0 commit comments

Comments
 (0)