Skip to content

Tagging Updates: Name #2322

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

Merged
merged 8 commits into from
Aug 5, 2019
Merged
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
2 changes: 1 addition & 1 deletion chalice/build_deploy_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fi

export DEPLOY_ORIGIN="$(whoami)-$(hostname)-$(git describe --tags --always)-$(date -u +'%Y-%m-%d-%H-%M-%S').deploy"
cat "$config_json" | jq ".stages.$stage.tags.DSS_DEPLOY_ORIGIN=\"$DEPLOY_ORIGIN\" | \
.stages.$stage.tags.Name=\"${DSS_INFRA_TAG_PROJECT}-${DSS_DEPLOYMENT_STAGE}-${DSS_INFRA_TAG_SERVICE}\" | \
.stages.$stage.tags.Name=\"${DSS_INFRA_TAG_SERVICE}-chalice\" | \
.stages.$stage.tags.service=\"${DSS_INFRA_TAG_SERVICE}\" | \
.stages.$stage.tags.project=\"$DSS_INFRA_TAG_PROJECT\" | \
.stages.$stage.tags.owner=\"${DSS_INFRA_TAG_OWNER}\" | \
Expand Down
3 changes: 2 additions & 1 deletion daemons/build_deploy_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ if [[ -z $DSS_DEPLOYMENT_STAGE ]]; then
fi

export daemon_name=$1
export daemon_tag=$(echo $daemon_name | cut -d '-' -f2-)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you edit the daemon name instead of just using daemon_name?

Copy link
Contributor Author

@amarjandu amarjandu Aug 5, 2019

Choose a reason for hiding this comment

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

its to strip out dss from the name to avoid dss-dss-operations-dev

export stage=$DSS_DEPLOYMENT_STAGE
export iam_role_name="${daemon_name}-${stage}"
config_json="$(dirname $0)/${daemon_name}/.chalice/config.json"
Expand All @@ -37,7 +38,7 @@ cat "$config_json" | jq ".stages.$stage.layers=[env.layer_version_arn]" | sponge

export DEPLOY_ORIGIN="$(whoami)-$(hostname)-$(git describe --tags --always)-$(date -u +'%Y-%m-%d-%H-%M-%S').deploy"
cat "$config_json" | jq ".stages.$stage.tags.DSS_DEPLOY_ORIGIN=\"$DEPLOY_ORIGIN\" | \
.stages.$stage.tags.Name=\"${DSS_INFRA_TAG_PROJECT}-${DSS_DEPLOYMENT_STAGE}-${DSS_INFRA_TAG_SERVICE}\" | \
.stages.$stage.tags.Name=\"${DSS_INFRA_TAG_SERVICE}-$daemon_tag\" | \
.stages.$stage.tags.service=\"${DSS_INFRA_TAG_SERVICE}\" | \
.stages.$stage.tags.project=\"$DSS_INFRA_TAG_PROJECT\" | \
.stages.$stage.tags.owner=\"${DSS_INFRA_TAG_OWNER}\" | \
Expand Down
2 changes: 1 addition & 1 deletion infra/async_state_db/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ data "aws_caller_identity" "current" {}
locals {
common_tags = "${map(
"managedBy" , "terraform",
"Name" , "${var.DSS_INFRA_TAG_PROJECT}-${var.DSS_DEPLOYMENT_STAGE}-${var.DSS_INFRA_TAG_SERVICE}",
"Name" , "${var.DSS_INFRA_TAG_SERVICE}-asyncdynamodb",
"project" , "${var.DSS_INFRA_TAG_PROJECT}",
"env" , "${var.DSS_DEPLOYMENT_STAGE}",
"service" , "${var.DSS_INFRA_TAG_SERVICE}",
Expand Down
13 changes: 12 additions & 1 deletion infra/buckets/gs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ resource google_storage_bucket dss_gs_bucket {
provider = "google"
location = "US"
storage_class = "MULTI_REGIONAL"
labels = "${merge(local.common_tags, local.gcp_tags)}"
}

resource google_storage_bucket dss_gs_bucket_test {
Expand All @@ -11,6 +12,7 @@ resource google_storage_bucket dss_gs_bucket_test {
provider = "google"
location = "US"
storage_class = "MULTI_REGIONAL"
labels = "${merge(local.common_tags, local.gcp_tags)}"
lifecycle_rule {
action {
type = "Delete"
Expand All @@ -28,13 +30,15 @@ resource google_storage_bucket dss_gs_bucket_test_fixtures {
provider = "google"
location = "US"
storage_class = "MULTI_REGIONAL"
labels = "${merge(local.common_tags, local.gcp_tags)}"
}

resource google_storage_bucket dss_gs_checkout_bucket {
name = "${var.DSS_GS_CHECKOUT_BUCKET}"
provider = "google"
location = "US"
storage_class = "MULTI_REGIONAL"
labels = "${merge(local.common_tags, local.gcp_tags)}"
lifecycle_rule {
action {
type = "Delete"
Expand All @@ -48,7 +52,12 @@ resource google_storage_bucket dss_gs_checkout_bucket {
}

locals {
checkout_bucket_viewers = "${compact(split(",", var.DSS_CHECKOUT_BUCKET_OBJECT_VIEWERS))}"
checkout_bucket_viewers = "${compact(split(",", var.DSS_CHECKOUT_BUCKET_OBJECT_VIEWERS))}",
gcp_tags = "${map(
"name" , "${var.DSS_INFRA_TAG_SERVICE}-gs-storage",
"owner" , "${element(split("@", var.DSS_INFRA_TAG_OWNER),0)}",
"managed-by" , "terraform"
)}"
}

resource "google_storage_bucket_iam_member" "checkout_viewer" {
Expand All @@ -64,6 +73,7 @@ resource google_storage_bucket dss_gs_checkout_bucket_test {
provider = "google"
location = "US"
storage_class = "MULTI_REGIONAL"
labels = "${merge(local.common_tags, local.gcp_tags)}"
lifecycle_rule {
action {
type = "Delete"
Expand All @@ -81,6 +91,7 @@ resource google_storage_bucket dss_gs_checkout_bucket_test_user {
provider = "google"
location = "US"
storage_class = "MULTI_REGIONAL"
labels = "${merge(local.common_tags, local.gcp_tags)}"
lifecycle_rule {
action {
type = "Delete"
Expand Down
24 changes: 13 additions & 11 deletions infra/buckets/s3.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ data "aws_caller_identity" "current" {}

locals {
common_tags = "${map(
"managedBy" , "terraform",
"Name" , "${var.DSS_INFRA_TAG_PROJECT}-${var.DSS_DEPLOYMENT_STAGE}-${var.DSS_INFRA_TAG_SERVICE}",
"project" , "${var.DSS_INFRA_TAG_PROJECT}",
"env" , "${var.DSS_DEPLOYMENT_STAGE}",
"service" , "${var.DSS_INFRA_TAG_SERVICE}",
"owner" , "${var.DSS_INFRA_TAG_OWNER}"
"service" , "${var.DSS_INFRA_TAG_SERVICE}"
)}",
aws_tags = "${map(
"Name" , "${var.DSS_INFRA_TAG_SERVICE}-s3-storage",
"owner" , "${var.DSS_INFRA_TAG_OWNER}",
"managedBy" , "terraform"
)}"
}

Expand All @@ -17,7 +19,7 @@ resource aws_s3_bucket dss_s3_bucket {
server_side_encryption_configuration {
rule {apply_server_side_encryption_by_default {sse_algorithm = "AES256"}}
}
tags = "${local.common_tags}"
tags = "${merge(local.common_tags, local.aws_tags)}"
}

resource aws_s3_bucket dss_s3_bucket_test {
Expand All @@ -31,13 +33,13 @@ resource aws_s3_bucket dss_s3_bucket_test {
days = "${var.DSS_BLOB_TTL_DAYS}"
}
}
tags = "${local.common_tags}"
tags = "${merge(local.common_tags, local.aws_tags)}"
}

resource aws_s3_bucket dss_s3_bucket_test_fixtures {
count = "${var.DSS_DEPLOYMENT_STAGE == "dev" ? 1 : 0}"
bucket = "${var.DSS_S3_BUCKET_TEST_FIXTURES}"
tags = "${local.common_tags}"
tags = "${merge(local.common_tags, local.aws_tags)}"
}

resource aws_s3_bucket dss_s3_checkout_bucket {
Expand All @@ -61,7 +63,7 @@ resource aws_s3_bucket dss_s3_checkout_bucket {
enabled = true
abort_incomplete_multipart_upload_days = "${var.DSS_BLOB_TTL_DAYS}"
}
tags = "${local.common_tags}"
tags = "${merge(local.common_tags, local.aws_tags)}"
cors_rule {
allowed_methods = [
"HEAD",
Expand All @@ -88,7 +90,7 @@ resource aws_s3_bucket dss_s3_checkout_bucket_test {
days = "${var.DSS_BLOB_TTL_DAYS}"
}
}
tags = "${local.common_tags}"
tags = "${merge(local.common_tags, local.aws_tags)}"
}

resource aws_s3_bucket dss_s3_checkout_bucket_test_user {
Expand All @@ -102,13 +104,13 @@ resource aws_s3_bucket dss_s3_checkout_bucket_test_user {
days = "${var.DSS_BLOB_TTL_DAYS}"
}
}
tags = "${local.common_tags}"
tags = "${merge(local.common_tags, local.aws_tags)}"
}

resource aws_s3_bucket dss_s3_checkout_bucket_unwritable {
count = "${var.DSS_DEPLOYMENT_STAGE == "dev" ? 1 : 0}"
bucket = "${var.DSS_S3_CHECKOUT_BUCKET_UNWRITABLE}"
tags = "${local.common_tags}"
tags = "${merge(local.common_tags, local.aws_tags)}"
policy = <<POLICY
{
"Version": "2012-10-17",
Expand Down
2 changes: 1 addition & 1 deletion infra/collections_db/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ data "aws_caller_identity" "current" {}
locals {
common_tags = "${map(
"managedBy" , "terraform",
"Name" , "${var.DSS_INFRA_TAG_PROJECT}-${var.DSS_DEPLOYMENT_STAGE}-${var.DSS_INFRA_TAG_SERVICE}",
"Name" , "${var.DSS_INFRA_TAG_SERVICE}-collectionsdynamodb",
"project" , "${var.DSS_INFRA_TAG_PROJECT}",
"env" , "${var.DSS_DEPLOYMENT_STAGE}",
"service" , "${var.DSS_INFRA_TAG_SERVICE}",
Expand Down
2 changes: 1 addition & 1 deletion infra/elasticsearch/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ locals {
account_id = "${data.aws_caller_identity.current.account_id}"
common_tags = "${map(
"managedBy" , "terraform",
"Name" , "${var.DSS_INFRA_TAG_PROJECT}-${var.DSS_DEPLOYMENT_STAGE}-${var.DSS_INFRA_TAG_SERVICE}",
"Name" , "${var.DSS_INFRA_TAG_SERVICE}-elasticsearch",
"project" , "${var.DSS_INFRA_TAG_PROJECT}",
"env" , "${var.DSS_DEPLOYMENT_STAGE}",
"service" , "${var.DSS_INFRA_TAG_SERVICE}",
Expand Down
2 changes: 1 addition & 1 deletion infra/subscription_v2_db/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ data "aws_caller_identity" "current" {}
locals {
common_tags = "${map(
"managedBy" , "terraform",
"Name" , "${var.DSS_INFRA_TAG_PROJECT}-${var.DSS_DEPLOYMENT_STAGE}-${var.DSS_INFRA_TAG_SERVICE}",
"Name" , "${var.DSS_INFRA_TAG_SERVICE}-subscriptionsdynamodb",
"project" , "${var.DSS_INFRA_TAG_PROJECT}",
"env" , "${var.DSS_DEPLOYMENT_STAGE}",
"service" , "${var.DSS_INFRA_TAG_SERVICE}",
Expand Down