Skip to content

Commit

Permalink
add trigger-template to makefile for lambda generate
Browse files Browse the repository at this point in the history
  • Loading branch information
morga471 committed Jun 27, 2025
1 parent 78adde4 commit 54c720f
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 40 deletions.
9 changes: 9 additions & 0 deletions .github/platform-tg-infra.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@
},
{
"path": "../../repo-setup"
},
{
"path": "../../template-eks-cluster"
},
{
"path": "../../module-decomposition"
},
{
"path": "../../csvd-platform-lab-srn"
}
]
}
28 changes: 27 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: help config init validate plan fmt check clean deploy-to-pipeline tail parse
.PHONY: help config init validate plan fmt check clean deploy-to-pipeline tail parse trigger-template
# Default values
ENV ?= development
REGION_DIR ?= us-gov-east-1
Expand All @@ -14,6 +14,7 @@ help:
@echo " clean - Clean up Terragrunt cache and temporary files"
@echo " deploy-to-pipeline - Zip and upload to S3 to trigger CodePipeline"
@echo " tail - Tail the logs of the CodeBuild project"
@echo " trigger-template - Trigger template automation lambda with config.json"

# Shared configuration target that exports all variables
config:
Expand Down Expand Up @@ -139,3 +140,28 @@ tail: config
--since 1m \
--region $(AWS_REGION) \
--profile $(AWS_PROFILE)

# Template automation using lambda
trigger-template: config
@echo "Triggering template automation lambda..."
@if [ ! -f "config.json" ]; then \
echo "Error: config.json not found in current directory"; \
exit 1; \
fi

@echo "Invoking lambda function with config.json payload..."
aws lambda invoke \
--function-name arn:aws-us-gov:lambda:us-gov-west-1:229685449397:function:template-repos-template-automation \
--payload file://config.json \
--region us-gov-west-1 \
--profile $(AWS_PROFILE) \
--cli-binary-format raw-in-base64-out \
lambda-response.json

@echo "Lambda response:"
@cat lambda-response.json | jq '.' 2>/dev/null || cat lambda-response.json

@echo "Cleaning up response file..."
@rm -f lambda-response.json

@echo "Template automation lambda triggered successfully!"
15 changes: 2 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ make plan # Preview changes
make fmt # Format files
make check # Run all checks
make clean # Clean up temporary files
make deploy-to-piepeline # zip files and push to s3 for codepipeline
make trigger-template # trigger lambda with config.json to generate new cluster repo
```

### Manual Terragrunt Commands
Expand Down Expand Up @@ -93,23 +95,10 @@ Terragrunt configurations are organized like this:

Check the environment folders for more details.

## Testing

The `/tests` folder has tools to check if everything works. To run tests:

```bash
cd tests
./run_tests.sh
```

## How to Contribute

1. Make a copy of this repository
2. Create a new branch for your changes
3. Make your updates
4. Run `make check` to ensure everything is correct
5. Submit a pull request

## License

Copyright © 2025 Your Organization. All rights reserved.
40 changes: 40 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"body": {
"project_name": "csvd-platform-lab-mcm",
"owning_team": "tf-module-admins",
"template_settings": {
"environment": "development",
"region": "us-gov-east-1",
"cluster_dir": "csvd-platform-lab-mcm",
"enable_all_modules": true,
"account": {
"account_name": "lab-dev-ew",
"aws_account_id": "224384469011",
"aws_profile": "224384469011-lab-dev-ew",
"environment_abbr": "dev"
},
"vpc": {
"vpc_name": "vpc3-lab-dev",
"vpc_domain_name": "dev.lab.csp2.census.gov"
},
"cluster": {
"cluster_name": "csvd-platform-lab-mcm",
"cluster_mailing_list": "matthew.c.morgan@census.gov",
"eks_instance_disk_size": 200,
"eks_ng_desired_size": 2,
"eks_ng_max_size": 2,
"eks_ng_min_size": 2,
"organization": "census:ocio:csvd",
"finops_project_name": "csvd_platformbaseline",
"finops_project_number": "fs0000000078",
"finops_project_role": "csvd_platformbaseline_eks",
"tags": {
"slim:schedule": "8:00-17:00",
"environment": "development",
"owner": "matthew.c.morgan@census.gov",
"managed_by": "terragrunt"
}
}
}
}
}
26 changes: 0 additions & 26 deletions input_vars.hcl

This file was deleted.

0 comments on commit 54c720f

Please sign in to comment.