Skip to content

Commit e13a12d

Browse files
authored
Merge pull request #21 from alphagov/govsi-717-create-redis-in-for-am
GOVSI-717: Create Terraform and add Redis
2 parents ad950ff + f5c68ad commit e13a12d

12 files changed

Lines changed: 238 additions & 1 deletion

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,10 @@ logs*.json
120120
*.xlsx
121121

122122
keys/
123-
.vscode/
123+
.vscode/
124+
125+
# Terraform related files
126+
ci/terraform/.terraform
127+
*.tfstate
128+
*.tfstate.backup
129+
ci/terraform/*.plan
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
platform: linux
2+
image_resource:
3+
type: registry-image
4+
source:
5+
repository: hashicorp/terraform
6+
tag: 1.0.4
7+
username: ((docker-hub-username))
8+
password: ((docker-hub-password))
9+
params:
10+
DEPLOYER_ROLE_ARN: ((deployer-role-arn-non-prod))
11+
DEPLOY_ENVIRONMENT: build
12+
CF_USERNAME: ((cf-username))
13+
CF_PASSWORD: ((cf-password))
14+
CF_ORG_NAME: ((cf-org-name))
15+
inputs:
16+
- name: account-managment-release
17+
outputs:
18+
- name: terraform-outputs
19+
run:
20+
path: /bin/sh
21+
args:
22+
- -euc
23+
- |
24+
mkdir src
25+
tar xfz account-managment-release/source.tar.gz --strip-components=1 -C src/
26+
cd "src/ci/terraform/"
27+
terraform init -input=false \
28+
-backend-config "role_arn=${DEPLOYER_ROLE_ARN}" \
29+
-backend-config "bucket=digital-identity-dev-tfstate" \
30+
-backend-config "key=acct-mgmt-${DEPLOY_ENVIRONMENT}-terraform.tfstate" \
31+
-backend-config "encrypt=true" \
32+
-backend-config "region=eu-west-2"
33+
34+
terraform apply -auto-approve \
35+
-var "deployer_role_arn=${DEPLOYER_ROLE_ARN}" \
36+
-var "cf_space=${DEPLOY_ENVIRONMENT}" \
37+
-var "cf_username=${CF_USERNAME}" \
38+
-var "cf_password=${CF_PASSWORD}" \
39+
-var "cf_org_name=${CF_ORG_NAME}" \
40+
-var-file ${DEPLOY_ENVIRONMENT}.tfvars
41+
42+
terraform output --json > ../../../../terraform-outputs/${DEPLOY_ENVIRONMENT}-terraform-outputs.json

ci/terraform/.terraform-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.4

ci/terraform/.terraform.lock.hcl

Lines changed: 82 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ci/terraform/build.tfvars

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
redis_service_plan = "tiny-ha-5.x"
2+
cf_space_name = build
3+
cf_domain = "build.auth.ida.digital.cabinet-office.gov.uk"

ci/terraform/cf-data.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
data "cloudfoundry_org" "org" {
2+
name = var.cf_org_name
3+
}
4+
5+
data "cloudfoundry_space" "space" {
6+
name = var.cf_space_name
7+
org = data.cloudfoundry_org.org.id
8+
}
9+
10+
data "cloudfoundry_domain" "cloudapps" {
11+
name = var.cf_domain
12+
}

ci/terraform/integration.tfvars

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
redis_service_plan = "tiny-ha-5.x"
2+
cf_space_name = integration
3+
cf_domain = "integration.auth.ida.digital.cabinet-office.gov.uk"

ci/terraform/redis.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
data "cloudfoundry_service" "redis" {
2+
name = "redis"
3+
}
4+
5+
resource "cloudfoundry_service_instance" "redis" {
6+
name = "${var.cf_space_name}-redis"
7+
space = data.cloudfoundry_space.space.id
8+
service_plan = data.cloudfoundry_service.redis.service_plans["tiny-5_x"]
9+
}
10+

ci/terraform/sandpit.hcl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bucket = "digital-identity-dev-tfstate"
2+
key = "acct-mgmt-sandpit-terraform.tfstate"
3+
encrypt = true
4+
region = "eu-west-2"

ci/terraform/sandpit.tfvars

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cf_org_name = "gds-digital-identity-authentication"
2+
cf_domain = "sandpit.auth.ida.digital.cabinet-office.gov.uk"
3+
cf_space_name = "sandpit"

0 commit comments

Comments
 (0)