From 1ec3177a150980acc4b4d8c36e05f0867f10689f Mon Sep 17 00:00:00 2001 From: Reuben Dunn Date: Wed, 7 Jul 2021 13:56:19 +1200 Subject: [PATCH] Added managed policy examples --- .../managed-policy/existing-role/.gitignore | 1 + .../existing-role/.terraform-version | 1 + examples/managed-policy/existing-role/main.tf | 28 ++++++++++++++++++ .../managed-policy/existing-role/outputs.tf | 19 ++++++++++++ examples/managed-policy/existing-role/vars.tf | 10 +++++++ examples/managed-policy/new-role/.gitignore | 1 + .../new-role/.terraform-version | 1 + examples/managed-policy/new-role/main.tf | 29 +++++++++++++++++++ examples/managed-policy/new-role/outputs.tf | 19 ++++++++++++ examples/managed-policy/new-role/vars.tf | 15 ++++++++++ 10 files changed, 124 insertions(+) create mode 100644 examples/managed-policy/existing-role/.gitignore create mode 100644 examples/managed-policy/existing-role/.terraform-version create mode 100644 examples/managed-policy/existing-role/main.tf create mode 100644 examples/managed-policy/existing-role/outputs.tf create mode 100644 examples/managed-policy/existing-role/vars.tf create mode 100644 examples/managed-policy/new-role/.gitignore create mode 100644 examples/managed-policy/new-role/.terraform-version create mode 100644 examples/managed-policy/new-role/main.tf create mode 100644 examples/managed-policy/new-role/outputs.tf create mode 100644 examples/managed-policy/new-role/vars.tf diff --git a/examples/managed-policy/existing-role/.gitignore b/examples/managed-policy/existing-role/.gitignore new file mode 100644 index 0000000..174bcac --- /dev/null +++ b/examples/managed-policy/existing-role/.gitignore @@ -0,0 +1 @@ +terraform.tfvars \ No newline at end of file diff --git a/examples/managed-policy/existing-role/.terraform-version b/examples/managed-policy/existing-role/.terraform-version new file mode 100644 index 0000000..17bc232 --- /dev/null +++ b/examples/managed-policy/existing-role/.terraform-version @@ -0,0 +1 @@ +0.12.31 \ No newline at end of file diff --git a/examples/managed-policy/existing-role/main.tf b/examples/managed-policy/existing-role/main.tf new file mode 100644 index 0000000..39b6dbf --- /dev/null +++ b/examples/managed-policy/existing-role/main.tf @@ -0,0 +1,28 @@ +module "example" { + source = "../../../managed-policy" + + providers = { + aws = aws + } + create_role = false + + role_name = "ExampleManagedPolicyRoleStage" + + policy_name = "ExampleManagedPolicyAdditionalStage" + policy_description = "An additional example policy bound to the testing policy for the module." + policy_document_json = var.policy_document_json + + + tags = {"Resource Owner" = "Managed Policy Example"} +} + +provider "aws" { + region = var.region + + default_tags { + tags = { + "Environment" = "stage", + "Managed By" = "terraform" + } + } +} \ No newline at end of file diff --git a/examples/managed-policy/existing-role/outputs.tf b/examples/managed-policy/existing-role/outputs.tf new file mode 100644 index 0000000..f8f9733 --- /dev/null +++ b/examples/managed-policy/existing-role/outputs.tf @@ -0,0 +1,19 @@ +output "policy_name" { + value = module.example.policy_name +} + +output "policy_arn" { + value = module.example.policy_arn +} + +output "role_name" { + value = module.example.role_name +} + +output "role_arn" { + value = module.example.role_arn +} + +output "is_new_role" { + value = module.example.is_new_role +} \ No newline at end of file diff --git a/examples/managed-policy/existing-role/vars.tf b/examples/managed-policy/existing-role/vars.tf new file mode 100644 index 0000000..a4345c0 --- /dev/null +++ b/examples/managed-policy/existing-role/vars.tf @@ -0,0 +1,10 @@ + +variable "region" { + type = string + default = "ap-southeast-2" +} + +variable "policy_document_json" { + type = string + description = "JSON policy document" +} diff --git a/examples/managed-policy/new-role/.gitignore b/examples/managed-policy/new-role/.gitignore new file mode 100644 index 0000000..174bcac --- /dev/null +++ b/examples/managed-policy/new-role/.gitignore @@ -0,0 +1 @@ +terraform.tfvars \ No newline at end of file diff --git a/examples/managed-policy/new-role/.terraform-version b/examples/managed-policy/new-role/.terraform-version new file mode 100644 index 0000000..17bc232 --- /dev/null +++ b/examples/managed-policy/new-role/.terraform-version @@ -0,0 +1 @@ +0.12.31 \ No newline at end of file diff --git a/examples/managed-policy/new-role/main.tf b/examples/managed-policy/new-role/main.tf new file mode 100644 index 0000000..0ef6b72 --- /dev/null +++ b/examples/managed-policy/new-role/main.tf @@ -0,0 +1,29 @@ +module "example" { + source = "../../../managed-policy" + + providers = { + aws = aws + } + create_role = true + + role_name = "ExampleManagedPolicyRoleStage" + assume_role_policy_json = var.assume_role_policy_json + + policy_name = "ExampleManagedPolicyStage" + policy_description = "An example policy used for testing the module." + policy_document_json = var.policy_document_json + + + tags = {"Resource Owner" = "Managed Policy Example"} +} + +provider "aws" { + region = var.region + + default_tags { + tags = { + "Environment" = "stage", + "Managed By" = "terraform" + } + } +} \ No newline at end of file diff --git a/examples/managed-policy/new-role/outputs.tf b/examples/managed-policy/new-role/outputs.tf new file mode 100644 index 0000000..f8f9733 --- /dev/null +++ b/examples/managed-policy/new-role/outputs.tf @@ -0,0 +1,19 @@ +output "policy_name" { + value = module.example.policy_name +} + +output "policy_arn" { + value = module.example.policy_arn +} + +output "role_name" { + value = module.example.role_name +} + +output "role_arn" { + value = module.example.role_arn +} + +output "is_new_role" { + value = module.example.is_new_role +} \ No newline at end of file diff --git a/examples/managed-policy/new-role/vars.tf b/examples/managed-policy/new-role/vars.tf new file mode 100644 index 0000000..5e7b2fd --- /dev/null +++ b/examples/managed-policy/new-role/vars.tf @@ -0,0 +1,15 @@ + +variable "region" { + type = string + default = "ap-southeast-2" +} + +variable "policy_document_json" { + type = string + description = "JSON policy document" +} + +variable "assume_role_policy_json" { + type = string + description = "Json policy document" +}