-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…-automation CT-1354 manage api setup automation
- Loading branch information
Showing
35 changed files
with
913 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.terraform.lock.hcl | ||
.terraform | ||
terraform.tfstate | ||
terraform.tfstate.backup | ||
terraform.tfvars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
provider "aws" { | ||
allowed_account_ids = [var.aws_account] | ||
region = var.aws_region | ||
profile = var.aws_profile | ||
} | ||
|
||
variable "aws_profile" { | ||
type = string | ||
} | ||
variable "aws_region" { | ||
type = string | ||
} | ||
variable "aws_account" { | ||
type = string | ||
} | ||
|
||
data "aws_region" "current" {} | ||
data "aws_caller_identity" "current" {} | ||
|
||
# Create resources | ||
|
||
module "aws_storage" { | ||
source = "./modules/aws/storage" | ||
|
||
service_name = local.service_name | ||
} | ||
|
||
module "aws_policy" { | ||
source = "./modules/aws/policy" | ||
|
||
service_name = local.service_name | ||
bucket_arn = module.aws_storage.bucket_arn | ||
} | ||
|
||
module "aws_user" { | ||
source = "./modules/aws/user" | ||
|
||
service_name = local.service_name | ||
policy_arn = module.aws_policy.policy_arn | ||
} | ||
|
||
module "aws_user_rotate" { | ||
source = "./modules/aws/user" | ||
|
||
service_name = local.rotate_service_name | ||
policy_arn = module.aws_policy.policy_arn | ||
} | ||
|
||
# Outputs | ||
|
||
output "TEST_S3_REGION" { | ||
value = data.aws_region.current.id | ||
description = "Region where your S3 is located" | ||
} | ||
output "TEST_S3_KEY" { | ||
value = module.aws_user.access_key_id | ||
description = "First AWS key" | ||
} | ||
output "TEST_S3_SECRET" { | ||
value = module.aws_user.access_key_secret | ||
sensitive = true | ||
description = "First AWS secret" | ||
} | ||
output "TEST_S3_ROTATE_KEY" { | ||
value = module.aws_user_rotate.access_key_id | ||
description = "Second AWS key" | ||
} | ||
output "TEST_S3_ROTATE_SECRET" { | ||
value = module.aws_user_rotate.access_key_secret | ||
sensitive = true | ||
description = "Second AWS secret" | ||
} | ||
output "TEST_S3_FILES_BUCKET" { | ||
value = module.aws_storage.bucket_name | ||
description = "Name of file bucket on S3" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
provider "azurerm" { | ||
features {} | ||
tenant_id = var.azure_tenant_id | ||
subscription_id = var.azure_subscription_id | ||
} | ||
provider "azuread" { | ||
tenant_id = var.azure_tenant_id | ||
} | ||
|
||
variable "azure_storage_location" { | ||
type = string | ||
} | ||
variable "azure_tenant_id" { | ||
type = string | ||
} | ||
variable "azure_subscription_id" { | ||
type = string | ||
} | ||
|
||
data "azurerm_client_config" "current" {} | ||
data "azuread_client_config" "current" {} | ||
|
||
# Create resources | ||
|
||
resource "azurerm_resource_group" "mapi_resource_group" { | ||
name = "${var.name_prefix}-mapi_resource_group" | ||
location = var.azure_storage_location | ||
} | ||
|
||
module "azure_storage" { | ||
source = "./modules/azure/storage" | ||
|
||
resource_group_location = azurerm_resource_group.mapi_resource_group.location | ||
resource_group_uuid = substr(md5(azurerm_resource_group.mapi_resource_group.id), 0, 17) | ||
resource_group_name = azurerm_resource_group.mapi_resource_group.name | ||
files_container = "dummy" | ||
} | ||
|
||
# Outputs | ||
|
||
output "TEST_ABS_ACCOUNT_NAME" { | ||
value = module.azure_storage.storage_account_files_name | ||
description = "Name of Azure Storage account" | ||
} | ||
output "TEST_ABS_ACCOUNT_KEY" { | ||
value = module.azure_storage.storage_account_primary_access_key | ||
sensitive = true | ||
description = "First secret key for Azure Storage account" | ||
} | ||
output "TEST_ABS_CONTAINER_NAME" { | ||
value = module.azure_storage.storage_container_files_test_container_name | ||
description = "Name of container created inside Azure Storage Account" | ||
} | ||
output "TEST_ABS_REGION" { | ||
value = module.azure_storage.storage_account_location | ||
description = "Name of region where Azure Storage Account is located" | ||
} | ||
output "TEST_ABS_ROTATE_ACCOUNT_KEY" { | ||
value = module.azure_storage.storage_account_secondary_access_key | ||
sensitive = true | ||
description = "Second secret key for Azure Storage account" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
set -Eeuo pipefail | ||
|
||
cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
source ./functions.sh | ||
|
||
output_var 'TEST_S3_REGION' "$(terraform_output 'TEST_S3_REGION')" | ||
output_var 'TEST_S3_FILES_BUCKET' "$(terraform_output 'TEST_S3_FILES_BUCKET')" | ||
output_var 'TEST_S3_KEY' "$(terraform_output 'TEST_S3_KEY')" | ||
output_var 'TEST_S3_SECRET' "$(terraform_output 'TEST_S3_SECRET')" | ||
output_var 'TEST_S3_ROTATE_KEY' "$(terraform_output 'TEST_S3_ROTATE_KEY')" | ||
output_var 'TEST_S3_ROTATE_SECRET' "$(terraform_output 'TEST_S3_ROTATE_SECRET')" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
set -Eeuo pipefail | ||
|
||
cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
source ./functions.sh | ||
|
||
output_var 'TEST_ABS_ACCOUNT_KEY' "$(terraform_output 'TEST_ABS_ACCOUNT_KEY')" | ||
output_var 'TEST_ABS_ACCOUNT_NAME' "$(terraform_output 'TEST_ABS_ACCOUNT_NAME')" | ||
output_var 'TEST_ABS_CONTAINER_NAME' "$(terraform_output 'TEST_ABS_CONTAINER_NAME')" | ||
output_var 'TEST_ABS_REGION' "$(terraform_output 'TEST_ABS_REGION')" | ||
output_var 'TEST_ABS_ROTATE_ACCOUNT_KEY' "$(terraform_output 'TEST_ABS_ROTATE_ACCOUNT_KEY')" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
set -Eeuo pipefail | ||
|
||
cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
source ./functions.sh | ||
|
||
output_var 'TEST_GCS_REGION' "$(terraform_output 'TEST_GCS_REGION')" | ||
output_var 'TEST_GCS_FILES_BUCKET' "$(terraform_output 'TEST_GCS_FILES_BUCKET')" | ||
output_var_json 'TEST_GCS_KEYFILE_JSON' "$(terraform_output 'TEST_GCS_KEYFILE_JSON')" | ||
output_var_json 'TEST_GCS_KEYFILE_ROTATE_JSON' "$(terraform_output 'TEST_GCS_KEYFILE_ROTATE_JSON')" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
set -Eeuo pipefail | ||
|
||
SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
PROJECT_ROOT="${SCRIPT_PATH}/../.." | ||
|
||
terraform_output() { | ||
jq ".${1}.value" -r $PROJECT_ROOT/provisioning/tfoutput.json | ||
} | ||
|
||
terraform_output_json() { | ||
jq ".${1}.value" -r $PROJECT_ROOT/provisioning/tfoutput.json | jq -c | ||
} | ||
|
||
output_var() { | ||
echo "${1}=\"${2}\"" | ||
} | ||
|
||
output_var_json() { | ||
echo "${1}='${2}'" | ||
} | ||
|
||
output_file() { | ||
mkdir -p "${PROJECT_ROOT}/$(dirname "${1}")" | ||
echo "${2}" >"${PROJECT_ROOT}/${1}" | ||
} |
Oops, something went wrong.