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

Azure support #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
219 changes: 154 additions & 65 deletions bin/terraform.sh

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bootstrap/.terraform-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
latest:^0.11
0.11.10
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ provider "aws" {
# specified in the environment variables.
# This helps to prevent accidents.
allowed_account_ids = [
"${var.aws_account_id}",
"${var.account_id}",
]
}
4 changes: 2 additions & 2 deletions bootstrap/s3_bucket.tf → bootstrap/aws/s3_bucket.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ resource "aws_s3_bucket" "bucket" {
# This does not use default tag map merging because bootstrapping is special
# You should use default tag map merging elsewhere
tags {
"Name" = "Terraform Scaffold State File Bucket for account ${var.aws_account_id} in region ${var.region}"
"Name" = "Terraform Scaffold State File Bucket for account ${var.account_id} in region ${var.region}"
"Environment" = "${var.environment}"
"Project" = "${var.project}"
"Component" = "${var.component}"
"Account" = "${var.aws_account_id}"
"Account" = "${var.account_id}"
}
}
2 changes: 1 addition & 1 deletion bootstrap/variables.tf → bootstrap/aws/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ variable "project" {
description = "The name of the Project we are bootstrapping terraformscaffold for"
}

variable "aws_account_id" {
variable "account_id" {
type = "string"
description = "The AWS Account ID into which we are bootstrapping terraformscaffold"
}
Expand Down
3 changes: 3 additions & 0 deletions bootstrap/azurerm/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "bucket_name" {
value = "${azurerm_storage_container.container.id}"
}
1 change: 1 addition & 0 deletions bootstrap/azurerm/provider_azure.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
provider "azurerm" {}
60 changes: 60 additions & 0 deletions bootstrap/azurerm/storage_container.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* resource "aws_s3_bucket" "bucket" {
bucket = "${var.bucket_name}"
acl = "private"

force_destroy = "false"

versioning {
enabled = "true"
}

lifecycle_rule {
prefix = "/"
enabled = "true"

noncurrent_version_transition {
days = "30"
storage_class = "STANDARD_IA"
}

noncurrent_version_transition {
days = "60"
storage_class = "GLACIER"
}

noncurrent_version_expiration {
days = "90"
}
}

# This does not use default tag map merging because bootstrapping is special
# You should use default tag map merging elsewhere
tags {
"Name" = "Terraform Scaffold State File Bucket for account ${var.aws_account_id} in region ${var.region}"
"Environment" = "${var.environment}"
"Project" = "${var.project}"
"Component" = "${var.component}"
"Account" = "${var.aws_account_id}"
}
}
*/

resource "azurerm_resource_group" "container" {
name = "${lower(var.bucket_name)}"
location = "${var.region}"
}

resource "azurerm_storage_account" "container" {
name = "${var.project}${var.region}tfstate"
resource_group_name = "${azurerm_resource_group.container.name}"
location = "${var.region}"
account_tier = "Standard"
account_replication_type = "LRS"
}

resource "azurerm_storage_container" "container" {
name = "${lower(var.bucket_name)}"
resource_group_name = "${azurerm_resource_group.container.name}"
storage_account_name = "${azurerm_storage_account.container.name}"
container_access_type = "private"
}
31 changes: 31 additions & 0 deletions bootstrap/azurerm/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
variable "project" {
type = "string"
description = "The name of the Project we are bootstrapping terraformscaffold for"
}

variable "account_id" {
type = "string"
description = "The Azure Subscription ID into which we are bootstrapping terraformscaffold"
}

variable "region" {
type = "string"
description = "The Azure Region into which we are bootstrapping terraformscaffold"
}

variable "environment" {
type = "string"
description = "The name of the environment for the bootstrapping process; which is always bootstrap"
default = "bootstrap"
}

variable "component" {
type = "string"
description = "The name of the component for the bootstrapping process; which is always bootstrap"
default = "bootstrap"
}

variable "bucket_name" {
type = "string"
description = "The name to use for the terraformscaffold bucket"
}
22 changes: 22 additions & 0 deletions bootstrap/gcloud/gcp_bucket.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
resource "google_storage_bucket" "bucket" {
name = "${var.bucket_name}"
project = "${var.project}"

location = "${var.region}"
storage_class = "REGIONAL"

force_destroy = "false"

versioning { enabled = "true" }


# This does not use default tag map merging because bootstrapping is special
# You should use default tag map merging elsewhere
# labels = {
# "Name" = "Terraform Scaffold State File Bucket for account ${var.account_id} in region ${var.region}"
# "Environment" = "${var.environment}"
# "Account" = "${var.account_id}"
# "Component" = "${var.component}"
# }
}

3 changes: 3 additions & 0 deletions bootstrap/gcloud/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "bucket_name" {
value = "${google_storage_bucket.bucket.id}"
}
3 changes: 3 additions & 0 deletions bootstrap/gcloud/provider_gcp.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider "google" {
region = "${var.region}"
}
31 changes: 31 additions & 0 deletions bootstrap/gcloud/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
variable "project" {
type = "string"
description = "The name of the Project we are bootstrapping terraformscaffold for"
}

variable "account_id" {
type = "string"
description = "The AWS Account ID into which we are bootstrapping terraformscaffold"
}

variable "region" {
type = "string"
description = "The AWS Region into which we are bootstrapping terraformscaffold"
}

variable "environment" {
type = "string"
description = "The name of the environment for the bootstrapping process; which is always bootstrap"
default = "bootstrap"
}

variable "component" {
type = "string"
description = "The name of the component for the bootstrapping process; which is always bootstrap"
default = "bootstrap"
}

variable "bucket_name" {
type = "string"
description = "The name to use for the terraformscaffold bucket"
}