Skip to content

Commit

Permalink
add DNS code
Browse files Browse the repository at this point in the history
  • Loading branch information
nandajavarma committed Jun 23, 2022
1 parent 4c2b773 commit 84e477a
Show file tree
Hide file tree
Showing 10 changed files with 191 additions and 429 deletions.
7 changes: 5 additions & 2 deletions .werft/installer-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ const INFRA_PHASES: { [name: string]: InfraConfig } = {
},
DESTROY: {
phase: "destroy",
makeTarget: "cleanup",
makeTarget: `cleanup cloud=${cloud}`,
description: "Destroy the created infrastucture",
},
RESULTS: {
Expand Down Expand Up @@ -279,7 +279,10 @@ function cleanup() {
const phase = "destroy-infrastructure";
werft.phase(phase, "Destroying all the created resources");

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

// if the destroy command fail, we check if any resources are pending to be removed
// if nothing is yet to be cleaned, we return with success
Expand Down
34 changes: 26 additions & 8 deletions install/infra/terraform/aks/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,32 @@ output "external_dns_secrets" {
}

output "external_dns_settings" {
value = {
provider = "azure"
"azure.resourceGroup" = azurerm_resource_group.gitpod.name
"azure.subscriptionId" = data.azurerm_client_config.current.subscription_id
"azure.tenantId" = data.azurerm_client_config.current.tenant_id
"azure.useManagedIdentityExtension" = true
"azure.userAssignedIdentityID" = azurerm_kubernetes_cluster.k8s.kubelet_identity.0.client_id
}
value = [
{
"name": "provider",
"value": "azure"
},
{
"name": "azure.resourceGroup",
"value": azurerm_resource_group.gitpod.name,
},
{
"name": "azure.subscriptionId",
"value": data.azurerm_client_config.current.subscription_id,
},
{
"name": "azure.tenantId",
"value": data.azurerm_client_config.current.tenant_id,
},
{
"name": "azure.useManagedIdentityExtension",
"value": true
},
{
"name": "azure.userAssignedIdentityID",
"value": azurerm_kubernetes_cluster.k8s.kubelet_identity.0.client_id
},
]
}

output "k8s_connection" {
Expand Down
76 changes: 76 additions & 0 deletions install/infra/terraform/eks/dns.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
variable "domain_name" {}
variable "cluster_name" {}

terraform {
required_providers {
aws = {
version = " ~> 3.0"
source = "registry.terraform.io/hashicorp/aws"
}
}
}

provider "aws" {
region = "eu-west-1"
}

resource "aws_route53_zone" "gitpod" {
name = var.domain_name

tags = {
Environment = "test"
}
}

resource "aws_iam_policy" "gitpod" {
name = "role-${var.cluster_name}"

# Terraform's "jsonencode" function converts a
# Terraform expression result to valid JSON syntax.
policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Effect = "Allow",
Action = [
"route53:ChangeResourceRecordSets"
],
Resource = [
"arn:aws:route53:::hostedzone/*"
]
},
{
Effect = "Allow",
Action = [
"route53:ListHostedZones",
"route53:ListResourceRecordSets"
],
Resource = [ "*" ]
}
],
})
}

resource "aws_iam_role" "gitpod" {
name = "iam-route53-${var.cluster_name}"

assume_role_policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
POLICY
}

resource "aws_iam_role_policy_attachment" "route53" {
policy_arn = resource.aws_iam_policy.gitpod.arn
role = aws_iam_role.gitpod.name
}
203 changes: 0 additions & 203 deletions install/infra/terraform/eks/kubernetes.tf

This file was deleted.

Loading

0 comments on commit 84e477a

Please sign in to comment.