Skip to content

Commit 7c86391

Browse files
committed
fix: terraform runner container dependencies
Also improves logging of cron process.
1 parent 0573a2c commit 7c86391

File tree

5 files changed

+76
-38
lines changed

5 files changed

+76
-38
lines changed

CHANGELOG.md

Lines changed: 60 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,154 +1,188 @@
11
# Changelog
22

3-
## vNEXT
3+
## v1.8.0
44

55
### OSB
66

77
Breaking Changes:
88

9-
- unipipe service broker now uses `main` as the default branch instead of `master` to better align with defaults set up
10-
by most git hosting platforms. Please make sure you explicitly configure `GIT_REMOTE_BRANCH`
9+
- unipipe service broker now uses `main` as the default branch instead of `master` to better align with defaults set up
10+
by most git hosting platforms. Please make sure you explicitly configure `GIT_REMOTE_BRANCH`
1111
(see [configuration reference](https://github.com/meshcloud/unipipe-service-broker/wiki/Reference#configuration-reference))
1212
to avoid any unexpected change in branch.
1313

14+
### Terraform Runner
15+
16+
- make cron logs visible
17+
- add missing dependencies to container
18+
- require `GIT_REMOTE_BRANCH`
1419

1520
## v1.7.8
1621

1722
### CLI
23+
1824
- no changes
1925

2026
### OSB
27+
2128
- no changes
2229

2330
### Terraform Runner
31+
2432
- fix issue with cron invocation
2533

2634
## v1.7.7
2735

2836
### CLI
37+
2938
- no changes
3039

3140
### OSB
41+
3242
- update base docker image
3343

3444
### Terraform Runner
45+
3546
- update base docker image
3647
- update terraform to v1.3.10
3748

3849
## v1.7.6
3950

4051
### CLI
52+
4153
- no changes
4254

4355
### OSB
56+
4457
- fix getServiceInstanceBinding endpoint to return a 404, if binding does not exist
4558

4659
### Terraform Runner
60+
4761
- update terraform to v1.3.7
4862
- env variable KNWON_HOSTS now supports empty values
4963

5064
## v1.7.5
5165

5266
### CLI
67+
5368
- no changes
5469

5570
### OSB
71+
5672
- Fixed a bug that prevented a ServiceInstance update request to get executed if planId was null
5773

5874
### Terraform Runner
75+
5976
- Configure known hosts via environment variable
6077

6178
## v1.7.4
6279

6380
### Terraform Runner
81+
6482
- Configure known hosts via environment variable
6583

6684
## v1.7.3
6785

6886
### CLI
87+
6988
- New command `unipipe git` runs Git pull/push commands resiliently. It takes care of retrying and rebasing if needed to make sure a push will be successful.
7089

7190
### OSB
91+
7292
- no changes
7393

7494
### Terraform Runner
95+
7596
- Improve terraform-runner to use the new `unipipe git` command for Git operations.
7697

7798
## v1.7.2
7899

79100
### CLI
101+
80102
- new command unipipe generate terraform-runner-hello-world will generate a sample catalog + terraform files for use with unipipe terraform command
81103

82104
### Terraform Runner
105+
83106
- Improve runner script robustness
84107
- Abort cron job if Git repo setup fails
85108

86109
### OSB
110+
87111
- no changes
88112

89113
## v1.7.1
90114

91115
### Terraform Runner
116+
92117
- terraform-runner fix for Azure Container Instances
93118

94119
### CLI
120+
95121
- no changes
96122

97123
### OSB
124+
98125
- no changes
99126

100127
## v1.7.0
128+
101129
### CLI
102130

103131
- Fixed zsh completions
104132
- `unipipe terraform` updates status.yml to succeeded for service instances without any binding
105133
- A `UniPipe Terraform Runner` docker container is now available. You can find the versioned containers
106-
[here](https://github.com/meshcloud/unipipe-service-broker/pkgs/container/unipipe-terraform-runner).
107-
It can be configured via a few environment variables and executes `unipipe terraform` every minute
108-
for the configured git repository. It also pulls changes from and pushes updated status.yml files,
109-
etc to the configured git repository. Using this `UniPipe Terraform Runner` together with the
110-
`UniPipe Service Broker` results in a fully functional service broker.
134+
[here](https://github.com/meshcloud/unipipe-service-broker/pkgs/container/unipipe-terraform-runner).
135+
It can be configured via a few environment variables and executes `unipipe terraform` every minute
136+
for the configured git repository. It also pulls changes from and pushes updated status.yml files,
137+
etc to the configured git repository. Using this `UniPipe Terraform Runner` together with the
138+
`UniPipe Service Broker` results in a fully functional service broker.
111139
- Fixed mixed up plan and service column in `unipipe list` command. Service names are now shown
112-
in the Service column and plans are shown in the Plan column.
140+
in the Service column and plans are shown in the Plan column.
113141
- Added manual parameter input to `unipipe terraform` processing. This can be used if before executing
114-
Terraform for a Service Instance, an operator needs to take some manual action and provide additional
115-
input to the Terraform module. This can be used to e.g. provide an IP range for a service instance of a
116-
networking service, if no IPAM solution is in place. The operator just needs to put a `params.yml` in
117-
the according instance folder. Once this file is available the `unipipe terraform` command will apply Terraform.
118-
Whether a service requires this manual input can be defined in the metadata of a Service Plan in the service catalog.
142+
Terraform for a Service Instance, an operator needs to take some manual action and provide additional
143+
input to the Terraform module. This can be used to e.g. provide an IP range for a service instance of a
144+
networking service, if no IPAM solution is in place. The operator just needs to put a `params.yml` in
145+
the according instance folder. Once this file is available the `unipipe terraform` command will apply Terraform.
146+
Whether a service requires this manual input can be defined in the metadata of a Service Plan in the service catalog.
119147
- Support usage of Terraform Backend for `unipipe terraform` command. If a backend.tf file exists in the service's
120-
terraform folder it is copied to the binding directory where Terraform is executed. No configuration of
121-
the backend.tf can be done. The file will be used as is. In order to separate the different tfstates in the backend,
122-
the `unipipe terraform` command uses Terraform Workspaces. A workspace will be created for every service binding.
123-
Credentials for accessing the backend have to be set via environment variables. If e.g. an azure backend is used,
124-
ARM_CLIENT_ID and ARM_CLIENT_SECRET have to be set.
148+
terraform folder it is copied to the binding directory where Terraform is executed. No configuration of
149+
the backend.tf can be done. The file will be used as is. In order to separate the different tfstates in the backend,
150+
the `unipipe terraform` command uses Terraform Workspaces. A workspace will be created for every service binding.
151+
Credentials for accessing the backend have to be set via environment variables. If e.g. an azure backend is used,
152+
ARM_CLIENT_ID and ARM_CLIENT_SECRET have to be set.
125153
- `unipipe terraform` now supports the full lifecycle of a service instance. If a service instance or its binding is
126-
deleted, the `unipipe terraform` command applies a `terraform destroy` to remove the instance again.
154+
deleted, the `unipipe terraform` command applies a `terraform destroy` to remove the instance again.
127155
- It is now possible to add a `--plan` option to `unipipe terraform`, which executes the command basically as a dry-run.
128-
Instead of doing `terraform apply`, a `terraform plan` is executed and the console output shows the result of `terraform plan`.
129-
No status.yml is updated in this case.
156+
Instead of doing `terraform apply`, a `terraform plan` is executed and the console output shows the result of `terraform plan`.
157+
No status.yml is updated in this case.
130158
- `unipipe terraform` provides the plan_id and plan_name as variables to the Terraform module.
131159

132160
### OSB
161+
133162
- no changes
134163

135164
## v1.6.0
165+
136166
### CLI
137167

138168
- Added a new `unipipe terraform` command to execute Terraform modules easily. For several service brokers execution
139-
of a Terraform Module is the central task they have to execute. The Terraform module must exist in the git repository
140-
that also contains the instances in a terraform/<serviceId> folder. It must be compatible with a specific set of variables
141-
that will be provided to it via the unipipe terraform command. These variables are determined dynamically via the parameters
142-
and bindResource information provided by the UniPipe Service Broker.
169+
of a Terraform Module is the central task they have to execute. The Terraform module must exist in the git repository
170+
that also contains the instances in a terraform/<serviceId> folder. It must be compatible with a specific set of variables
171+
that will be provided to it via the unipipe terraform command. These variables are determined dynamically via the parameters
172+
and bindResource information provided by the UniPipe Service Broker.
143173

144174
### OSB
175+
145176
- no changes
146177

147178
## v1.5.2
179+
148180
### CLI
181+
149182
- no changes
150183

151184
### OSB
185+
152186
- fix: handling x-forward-headers
153187

154188
## v1.5.0

terraform-runner/Dockerfile

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
FROM ubuntu:jammy
22

3-
# RUN apt-get
4-
# RUN apk add curl bash sudo jq git openssh
53
RUN apt-get update && \
6-
apt-get install -y --no-install-recommends curl jq cron ca-certificates && \
4+
apt-get install -y --no-install-recommends curl jq cron ca-certificates git ssh && \
75
rm -rf /var/lib/apt/lists/*
86

97
# terraform
@@ -12,11 +10,6 @@ COPY --from=hashicorp/terraform:1.3.10 /bin/terraform /usr/local/bin/terraform
1210
# unipipe cli
1311
RUN curl https://raw.githubusercontent.com/meshcloud/unipipe-service-broker/main/cli/install.sh | bash
1412

15-
# unipipe terraform cron
16-
COPY unipipe-terraform-cron /etc/cron.d/unipipe-terraform-cron
17-
RUN chmod 0644 /etc/cron.d/unipipe-terraform-cron
18-
RUN crontab /etc/cron.d/unipipe-terraform-cron
19-
2013
RUN mkdir ~/unipipe
2114
COPY run-unipipe-terraform.sh /root/unipipe/run-unipipe-terraform.sh
2215
RUN chmod 0755 ~/unipipe/run-unipipe-terraform.sh

terraform-runner/entry.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
#!/usr/bin/env bash
22

3-
if [[ -z "$GIT_SSH_KEY" ]] || [[ -z "$GIT_USER_EMAIL" ]] || [[ -z "$GIT_USER_NAME" ]] || [[ -z "$GIT_REMOTE" ]] || [[ -z "$TF_VAR_platform_secret" ]]; then
4-
echo "Container failed to start, please provide all of the following environment variables: GIT_SSH_KEY, GIT_USER_EMAIL, GIT_USER_NAME, GIT_REMOTE, TF_VAR_platform_secret"
3+
if [[ -z "$GIT_SSH_KEY" ]] || [[ -z "$GIT_USER_EMAIL" ]] || [[ -z "$GIT_USER_NAME" ]] || [[ -z "$GIT_REMOTE" ]] || [[ -z "$GIT_REMOTE_BRANCH" ]] || [[ -z "$TF_VAR_platform_secret" ]]; then
4+
echo "Container failed to start, please provide all of the following environment variables: GIT_SSH_KEY, GIT_USER_EMAIL, GIT_USER_NAME, GIT_REMOTE, GIT_REMOTE_BRANCH, TF_VAR_platform_secret"
55
exit 1
66
else
77
echo "All required environment variables set!"
8+
{
9+
printf 'export GIT_SSH_KEY="%s"\n' "$GIT_SSH_KEY"
10+
printf 'export GIT_USER_EMAIL="%s"\n' "$GIT_USER_EMAIL"
11+
printf 'export GIT_USER_NAME="%s"\n' "$GIT_USER_NAME"
12+
printf 'export GIT_REMOTE="%s"\n' "$GIT_REMOTE"
13+
printf 'export GIT_REMOTE_BRANCH="%s"\n' "$GIT_REMOTE_BRANCH"
14+
printf 'export TF_VAR_platform_secret="%s"\n' "$TF_VAR_platform_secret"
15+
} > ~/unipipe/terraform-runner-env.sh
16+
17+
echo '* * * * * ~/unipipe/run-unipipe-terraform.sh > /proc/1/fd/1 2>/proc/1/fd/2' | crontab -
818
fi
919

1020
"$@"

terraform-runner/run-unipipe-terraform.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ set -o errexit
33
set -o errtrace
44
set -o pipefail
55

6+
source ~/unipipe/terraform-runner-env.sh
7+
68
if [[ -n $KNOWN_HOSTS ]]; then
79
echo "$KNOWN_HOSTS" > ~/.ssh/known_hosts
810
fi
@@ -16,7 +18,7 @@ if [[ ! -d "$REPO_DIR" ]]; then
1618
cd ~/unipipe
1719
git config --global user.email "$GIT_USER_EMAIL"
1820
git config --global user.name "$GIT_USER_NAME"
19-
git clone "$GIT_REMOTE" "$REPO_NAME"
21+
git clone "$GIT_REMOTE" "$REPO_NAME" -b "$GIT_REMOTE_BRANCH"
2022
fi
2123

2224
cd $REPO_DIR

terraform-runner/unipipe-terraform-cron

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)