Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactor & e2e test #2

Merged
merged 19 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .config/functional_tests/post-entrypoint-helpers.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#!/bin/bash
## NOTE: this script runs at the end of functional test
## Use this to load any configurations after the functional test
## Use this to load any configurations after the functional test
## TIPS: avoid modifying the .project_automation/functional_test/entrypoint.sh
## migrate any customization you did on entrypoint.sh to this helper script
echo "Executing Post-Entrypoint Helpers"
echo "Executing Post-Entrypoint Helpers"

#********** Project Path *************
PROJECT_PATH=${BASE_PATH}/project
PROJECT_TYPE_PATH=${BASE_PATH}/projecttype
cd ${PROJECT_PATH}

#********** CLEANUP *************
echo "Cleaning up all temp files and artifacts"
cd ${PROJECT_PATH}
make -s clean
19 changes: 17 additions & 2 deletions .config/functional_tests/pre-entrypoint-helpers.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
#!/bin/bash
## NOTE: this script runs at the start of functional test
## use this to load any configuration before the functional test
## use this to load any configuration before the functional test
## TIPS: avoid modifying the .project_automation/functional_test/entrypoint.sh
## migrate any customization you did on entrypoint.sh to this helper script
echo "Executing Pre-Entrypoint Helpers"
echo "Executing Pre-Entrypoint Helpers"


#********** Project Path *************
PROJECT_PATH=${BASE_PATH}/project
PROJECT_TYPE_PATH=${BASE_PATH}/projecttype
cd ${PROJECT_PATH}

#********** TFC Env Vars *************
export AWS_DEFAULT_REGION=us-west-2
export TFE_TOKEN=`aws secretsmanager get-secret-value --secret-id abp/hcp/token --region $AWS_DEFAULT_REGION | jq -r ".SecretString"`
export TF_TOKEN_app_terraform_io=`aws secretsmanager get-secret-value --secret-id abp/hcp/token --region $AWS_DEFAULT_REGION | jq -r ".SecretString"`

#********** MAKEFILE *************
echo "Build the lambda function packages"
make all
2 changes: 1 addition & 1 deletion .config/static_tests/post-entrypoint-helpers.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
## NOTE: this script runs at the end of static test
## Use this to load any configurations after the static test
## Use this to load any configurations after the static test
## TIPS: avoid modifying the .project_automation/static_test/entrypoint.sh
## migrate any customization you did on entrypoint.sh to this helper script
echo "Executing Post-Entrypoint Helpers"
2 changes: 1 addition & 1 deletion .config/static_tests/pre-entrypoint-helpers.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
## NOTE: this script runs at the start of static test
## use this to load any configuration before the static test
## use this to load any configuration before the static test
## TIPS: avoid modifying the .project_automation/static_test/entrypoint.sh
## migrate any customization you did on entrypoint.sh to this helper script
echo "Executing Pre-Entrypoint Helpers"
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Local .terraform directories
**/.terraform/*
**/.terraform

# .tfstate files
*.tfstate
Expand Down Expand Up @@ -40,4 +41,6 @@ terraform.rc

**/site-packages
*.zip
settings.json
settings.json
TODO.md
.DS_Store
32 changes: 29 additions & 3 deletions .header.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
# terraform-aws-plan-analyzer-runtask
# Runtask Terraform Plan Analyzer
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wellsiau-aws let's rename to Terraform run task plan analyzer


Use this module to develop HCP Terraform run task and deploy it in AWS.
## Overview

Integrate Amazon Bedrock to your HashiCorp Cloud Platform Terraform (Terraform Cloud) Run Tasks for:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prev. Terraform Cloud and "run tasks" start with small letters


* Analyzing Terraform plan and generate short-summary

* Function calling for other API-based analysis (e.g AMI analysis)

### Terraform plan summary

![Example](./images/example.png)

### Function calling (AMI analysis)

![Example2](./images/example2.png)

## Architecture

![Diagram](./images/arch.png)

This module must be deployed in AWS account with access to Amazon Bedrock model. We recommend you to use hub-spoke model, by deploying this module in one dedicated account.

Please refer to the [best-practice](#best-practice) section below for more details.

## Prerequisites

To use this module you need have the following:
Expand All @@ -13,7 +33,13 @@ To use this module you need have the following:

## Usage

1. Reference the `examples/basic` folder on how to use this module
* Build and package the Lambda files

```
make all
```

* Reference the `examples/basic` folder on how to use this module

```sh
cd examples/basic
Expand Down
4 changes: 2 additions & 2 deletions .project_automation/functional_tests/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

## WARNING: DO NOT modify the content of entrypoint.sh
# Use ./config/functional_tests/pre-entrypoint-helpers.sh or ./config/functional_tests/post-entrypoint-helpers.sh
# Use ./config/functional_tests/pre-entrypoint-helpers.sh or ./config/functional_tests/post-entrypoint-helpers.sh
# to load any customizations or additional configurations

## NOTE: paths may differ when running in a managed task. To ensure behavior is consistent between
Expand All @@ -22,7 +22,7 @@ pre_entrypoint() {
post_entrypoint() {
if [ -f ${PROJECT_PATH}/.config/functional_tests/post-entrypoint-helpers.sh ]; then
echo "Post-entrypoint helper found"
source ${PROJECT_PATH}/.config/functional_tests/post-entrypoint-helpers.sh
source ${PROJECT_PATH}/.config/functional_tests/post-entrypoint-helpers.sh
echo "Post-entrypoint helper loaded"
else
echo "Post-entrypoint helper not found - skipped"
Expand Down
2 changes: 1 addition & 1 deletion .project_automation/functional_tests/functional_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if test -f ${MANDATORY_TEST_PATH}; then
else
echo "File ${MANDATORY_TEST_PATH} not found. You must include at least one test run in file ${MANDATORY_TEST_PATH}"
(exit 1)
fi
fi

if [ $? -eq 0 ]; then
echo "Terraform Test Successfull"
Expand Down
2 changes: 1 addition & 1 deletion .project_automation/publication/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM public.ecr.aws/codebuild/amazonlinux2-x86_64-standard:4.0
RUN yum install -y yum-utils && yum-config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo && yum install -y gh
RUN yum install -y yum-utils && yum-config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo && yum install -y gh
RUN pip install awscli
4 changes: 2 additions & 2 deletions .project_automation/static_tests/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

## WARNING: DO NOT modify the content of entrypoint.sh
# Use ./config/static_tests/pre-entrypoint-helpers.sh or ./config/static_tests/post-entrypoint-helpers.sh
# Use ./config/static_tests/pre-entrypoint-helpers.sh or ./config/static_tests/post-entrypoint-helpers.sh
# to load any customizations or additional configurations

## NOTE: paths may differ when running in a managed task. To ensure behavior is consistent between
Expand All @@ -22,7 +22,7 @@ pre_entrypoint() {
post_entrypoint() {
if [ -f ${PROJECT_PATH}/.config/static_tests/post-entrypoint-helpers.sh ]; then
echo "Post-entrypoint helper found"
source ${PROJECT_PATH}/.config/static_tests/post-entrypoint-helpers.sh
source ${PROJECT_PATH}/.config/static_tests/post-entrypoint-helpers.sh
echo "Post-entrypoint helper loaded"
else
echo "Post-entrypoint helper not found - skipped"
Expand Down
Loading