Skip to content

Commit 8721315

Browse files
committed
fix prettier errors
1 parent 0983606 commit 8721315

File tree

1 file changed

+54
-53
lines changed

1 file changed

+54
-53
lines changed

docs/opentofu-remote-state.md

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This allows deployments to be made from anywhere that can access the state
66
without corrupting or conflicting with any existing resources from previous
77
deployments.
88

9-
Using remote state is therefore strongly recommended for environments which
9+
Using remote state is therefore strongly recommended for environments which
1010
should only be instantiated once, e.g. `production` and `staging`.
1111

1212
This page provides guidance for configuring remote states using backends
@@ -31,20 +31,20 @@ but includes some missing details and is modified for common appliance workflows
3131

3232
1. Create the backend file:
3333

34-
```shell
35-
cp environments/site/tofu/example-backends/gitlab.tf environments/$ENV/tofu
36-
```
34+
```shell
35+
cp environments/site/tofu/example-backends/gitlab.tf environments/$ENV/tofu
36+
```
3737

3838
2. Modify `environments/$ENV/tofu/gitlab.tf` to set the default for the
3939
project ID. This can be found by clicking the 3-dot menu at the top right of
4040
the GitLab project page.
4141

42-
```terraform
43-
# environments/$ENV/tofu/backend.tf:
44-
terraform {
45-
backend "http" {}
46-
}
47-
```
42+
```terraform
43+
# environments/$ENV/tofu/backend.tf:
44+
terraform {
45+
backend "http" {}
46+
}
47+
```
4848

4949
3. Commit it.
5050

@@ -55,12 +55,12 @@ but includes some missing details and is modified for common appliance workflows
5555
1. Create an access token in the GitLab UI, using either:
5656

5757
a. If project access tokens are available, create one via
58-
Project > Settings > Access tokens.
59-
The token must have `Maintainer` role and `api` scope.
58+
Project > Settings > Access tokens.
59+
The token must have `Maintainer` role and `api` scope.
6060

6161
b. Otherwise create a personal access token via
62-
User profile > Preferences > Access tokens.
63-
The token must have `api` scope.
62+
User profile > Preferences > Access tokens.
63+
The token must have `api` scope.
6464

6565
Copy the generated secret and set an environment variable:
6666

@@ -74,17 +74,17 @@ but includes some missing details and is modified for common appliance workflows
7474
export TF_VAR_gitlab_username=$your_username
7575
```
7676

77-
4. With the environment activated, initialise OpenTofu.
77+
3. With the environment activated, initialise OpenTofu.
7878

79-
If no local state exists run:
79+
If no local state exists run:
8080

81-
```shell
82-
cd environments/$ENV/tofu/
83-
tofu init
84-
```
85-
86-
otherwise append `-migrate-state` to the `init` command to attempt to copy
87-
local state to the new backend.
81+
```shell
82+
cd environments/$ENV/tofu/
83+
tofu init
84+
```
85+
86+
otherwise append `-migrate-state` to the `init` command to attempt to copy
87+
local state to the new backend.
8888

8989
OpenTofu is now configured to use GitLab to store state for this environment.
9090

@@ -111,60 +111,61 @@ per-checkout configuration is required.
111111

112112
1. Create an S3 bucket with a name `${cluster_name}-${environment_name}-tfstate`
113113
where:
114-
- `CLUSTER_NAME` is defined in `environments/$ENV/tofu/main.tf`
115-
- `$ENVIRONMENT_NAME` is the name of the environment directory
116114

117-
e.g.
115+
- `CLUSTER_NAME` is defined in `environments/$ENV/tofu/main.tf`
116+
- `$ENVIRONMENT_NAME` is the name of the environment directory
117+
118+
e.g.
118119

119-
```shell
120-
openstack container create research-staging-tfstate
121-
```
120+
```shell
121+
openstack container create research-staging-tfstate
122+
```
122123

123124
2. Create `ec2` credentials:
124125

125-
```shell
126-
openstack ec2 credentials create
127-
```
126+
```shell
127+
openstack ec2 credentials create
128+
```
128129

129-
and make a note of the `access` field returned.
130+
and make a note of the `access` field returned.
130131

131132
3. Create the backend file:
132133

133-
```shell
134-
cp environments/site/tofu/example-backends/s3.tf environments/$ENV/tofu
135-
```
134+
```shell
135+
cp environments/site/tofu/example-backends/s3.tf environments/$ENV/tofu
136+
```
136137

137138
4. Modify `environments/$ENV/tofu/s3.tf` to set the default for `s3_backend_endpoint`.
138139
This is the radosgw address. If not known it can be determined by creating a
139140
public bucket, and then getting the URL using
140-
Project > Containers > (your public bucket) > Link
141+
Project > Containers > (your public bucket) > Link
141142
which provides a URL of the form `https://$ENDPOINT/swift/...`.
142143

143144
5. Add the following to `environments/$ENV/activate`:
144145

145-
```bash
146-
export AWS_ACCESS_KEY_ID=$EC2_CREDENTIALS_ACCESS
147-
export AWS_SECRET_ACCESS_KEY=$(openstack ec2 credentials show $AWS_ACCESS_KEY_ID -f value -c secret)
148-
```
149-
150-
replacing `$EC2_CREDENTIALS_ACCESS` with the `access` field of the created
151-
credentials.
146+
```bash
147+
export AWS_ACCESS_KEY_ID=$EC2_CREDENTIALS_ACCESS
148+
export AWS_SECRET_ACCESS_KEY=$(openstack ec2 credentials show $AWS_ACCESS_KEY_ID -f value -c secret)
149+
```
152150

153-
This avoids these credentials being persisted in local files.
151+
replacing `$EC2_CREDENTIALS_ACCESS` with the `access` field of the created
152+
credentials.
153+
154+
This avoids these credentials being persisted in local files.
154155

155156
6. Copy the lines above into your shell to set them for your current shell.
156157

157158
7. With the environment activated, initialise OpenTofu.
158159

159-
If no local state exists run:
160+
If no local state exists run:
161+
162+
```shell
163+
cd environments/$ENV/tofu/
164+
tofu init
165+
```
160166

161-
```shell
162-
cd environments/$ENV/tofu/
163-
tofu init
164-
```
165-
166-
otherwise append `-migrate-state` to the `init` command to attempt to copy
167-
local state to the new backend.
167+
otherwise append `-migrate-state` to the `init` command to attempt to copy
168+
local state to the new backend.
168169

169170
8. If this fails, try setting `use_path_style = true` in `environments/$ENV/tofu/s3.tf`.
170171

0 commit comments

Comments
 (0)