Skip to content

Commit e6c7451

Browse files
authored
fix(aws): Move to S3 backend instead of TFCloud. (#281)
1 parent a7d0bab commit e6c7451

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

.aws/.terraform-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.3.6
1+
v1.6.6

.aws/src/main.ts

+16-11
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { Construct } from 'constructs';
55
import { AwsProvider } from '@cdktf/provider-aws/lib/provider';
66
import { config } from './config';
7-
import { App, TerraformStack, CloudBackend, NamedCloudWorkspace } from 'cdktf';
7+
import { App, TerraformStack, S3Backend } from 'cdktf';
88
import { DataAwsRegion } from '@cdktf/provider-aws/lib/data-aws-region';
99
import { DataAwsCallerIdentity } from '@cdktf/provider-aws/lib/data-aws-caller-identity';
1010
import { AgentIamPolicies, DataFlowsIamRoles, CircleCiOIDC } from './iam';
@@ -250,17 +250,22 @@ const app = new App();
250250
const prefectStack = new PrefectV2(app, 'prefect-v2');
251251
const prefectOidc = new PrefectOidc(app, 'prefect-oidc');
252252

253-
new CloudBackend(prefectStack, {
254-
hostname: 'app.terraform.io',
255-
organization: 'Pocket',
256-
workspaces: new NamedCloudWorkspace(`prefect-v2-${config.tags.environment}`)
253+
let tfEnv = 'dev';
254+
if (config.tags.environment.toLowerCase() == 'production') {
255+
tfEnv = 'prod';
256+
}
257+
258+
new S3Backend(prefectStack, {
259+
bucket: `mozilla-content-team-${tfEnv}-terraform-state`,
260+
dynamodbTable: `mozilla-content-team-${tfEnv}-terraform-state`,
261+
key: `prefect-v2-${config.tags.environment.toLowerCase()}`,
262+
region: 'us-east-1'
257263
});
258-
new CloudBackend(prefectOidc, {
259-
hostname: 'app.terraform.io',
260-
organization: 'Pocket',
261-
workspaces: new NamedCloudWorkspace(
262-
`prefect-v2-circleci-${config.tags.environment}`
263-
)
264+
new S3Backend(prefectOidc, {
265+
bucket: `mozilla-content-team-${tfEnv}-terraform-state`,
266+
dynamodbTable: `mozilla-content-team-${tfEnv}-terraform-state`,
267+
key: `prefect-v2-circleci-${config.tags.environment.toLowerCase()}`,
268+
region: 'us-east-1'
264269
});
265270

266271
app.synth();

.circleci/workflows.yml

+6
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ jobs:
192192
- run:
193193
command: |
194194
cd .aws/cdktf.out/stacks/<< parameters.stack_name >>
195+
if [ ${NODE_ENV} == "development" ]
196+
then
197+
export TF_WORKSPACE=Dev
198+
else
199+
export TF_WORKSPACE=Prod
200+
fi
195201
terraform init
196202
if [[ ${APPLY_STACK} == "false" ]]
197203
then

0 commit comments

Comments
 (0)