Skip to content

Commit ad164d4

Browse files
tloubrieu-jplThomas Loubrieu
andauthored
Split terraform scripts according to lifecycle of the components (#550)
* split terraform scripts according to lifecycle of the components, validated in dev, without terragrunt * split terraform scripts according to lifecycle of the components, validated in dev, without terragrunt --------- Co-authored-by: Thomas Loubrieu <loubrieu@jpl.nasa.gov>
1 parent a0cda41 commit ad164d4

29 files changed

Lines changed: 302 additions & 338 deletions

terraform/README.md

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
# AWS OpenSearch Serverless Terraform Configuration
22

3-
This Terraform configuration creates an AWS OpenSearch Serverless collection with configurable backend state management.
3+
This Terraform configuration creates a PDS Registry with configurable backend state management.
4+
5+
It is divided into 3 scripts to match the lifecycle and update frequencies of the resources:
6+
7+
- `opensearch_<serverless|managed>` : to create the opensearch server containing the registry data
8+
- `security`: to create or update the opensearch data access policy, as needed
9+
- `applications`: to continuously deploy the upgraded applications (credentials, TODO: sweepers and api)
10+
11+
For development or test deployment we deploy the 3 scripts always.
12+
For production we only deploy `security` and `applications`, as needed.
413

514
## Prerequisites
615

@@ -23,51 +32,36 @@ Edit `backend-config.tfvars` with your S3 bucket details:
2332

2433
```hcl
2534
bucket = "your-terraform-state-bucket"
26-
key = "registry/opensearch/terraform.tfstate"
2735
region = "us-east-1"
2836
dynamodb_table = "terraform-state-lock"
2937
encrypt = true
3038
```
3139

3240
### 2. Configure Variables
3341

42+
In each script sub-directory (opensearch_*, security, applications)
43+
3444
Create a `terraform.tfvars` file from the example:
3545

3646
```bash
3747
cp terraform.tfvars.example terraform.tfvars
3848
```
3949

40-
Edit `terraform.tfvars` with your desired configuration:
50+
Edit `terraform.tfvars` with your desired configuration
4151

42-
```hcl
43-
aws_region = "us-east-1"
44-
collection_name = "my-registry-collection"
45-
environment = "dev"
46-
47-
# Add IAM principals that can access the collection
48-
allowed_principals = [
49-
"arn:aws:iam::123456789012:user/your-user",
50-
"arn:aws:iam::123456789012:role/your-role"
51-
]
52-
53-
# For public access
54-
enable_public_access = true
55-
56-
# OR for VPC-only access
57-
enable_public_access = false
58-
allowed_vpcs = ["vpce-1234567890abcdef0"]
59-
```
6052

6153
### 3. Initialize Terraform
6254

55+
In each sub-directory (security, opensearch_*, applications), in this order, as needed:
56+
6357
```bash
64-
terraform init -backend-config=backend-config.tfvars
58+
terraform init -backend-config=../backend-config.tfvars
6559
```
6660

6761
For local state (not recommended for production):
6862

6963
```bash
70-
terraform init
64+
terraform init -backend-config=.../backend-config.tfvars
7165
```
7266

7367
### 4. Plan and Apply
@@ -94,7 +88,7 @@ Edit it to change the access to public.
9488

9589
### Initialize the registry
9690

97-
The registry needs a schema to be intialized and for integration test purpose we also want to load some reference data in it. To do so, you can use the registry-loader utility as described in
91+
The registry needs a schema to be initialized and for integration test purpose we also want to load some reference data in it. To do so, you can use the registry-loader utility as described in
9892

9993
Most of the needed configuration is pulled from the terraform output but additional environment is required:
10094

File renamed without changes.
File renamed without changes.
File renamed without changes.

terraform/applications/backend.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
terraform {
2+
backend "s3" {
3+
# Backend configuration values provided via backend-config.tfvars
4+
# Example backend-config.tfvars content:
5+
# bucket = "pds-infra"
6+
key = "registry/applications.tfstate"
7+
# region = "us-east-1"
8+
# dynamodb_table = "terraform-state-lock"
9+
# encrypt = true
10+
# profile = "your-aws-profile"
11+
}
12+
}
File renamed without changes.

terraform/lambda/src/get_awskeys_from_cognitojwt.py renamed to terraform/applications/lambda/src/get_awskeys_from_cognitojwt.py

File renamed without changes.

0 commit comments

Comments
 (0)