-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
56 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
pipeline "tag_resources" { | ||
title = "Tag Resources" | ||
|
||
param "region" { | ||
type = string | ||
description = "The name of the Region." | ||
default = var.region | ||
} | ||
|
||
param "access_key_id" { | ||
type = string | ||
description = "The ID for this access key." | ||
default = var.access_key_id | ||
} | ||
|
||
param "secret_access_key" { | ||
type = string | ||
description = "The secret key used to sign requests." | ||
default = var.secret_access_key | ||
} | ||
|
||
param "resource_arns" { | ||
type = list(string) | ||
description = "Specifies the list of ARNs of the resources that you want to apply tags to." | ||
} | ||
|
||
param "tags" { | ||
type = map(string) | ||
description = "Specifies a list of tags that you want to add to the specified resources. A tag consists of a key and a value that you define." | ||
} | ||
|
||
step "container" "tag_resources" { | ||
image = "amazon/aws-cli" | ||
|
||
cmd = concat( | ||
["resourcegroupstaggingapi", "tag-resources", "--resource-arn-list"], | ||
param.resource_arns, | ||
["--tags"], | ||
[join(",", [for key, value in param.tags: "${key}=${value}"])] | ||
) | ||
|
||
env = { | ||
AWS_REGION = param.region | ||
AWS_ACCESS_KEY_ID = param.access_key_id | ||
AWS_SECRET_ACCESS_KEY = param.secret_access_key | ||
} | ||
} | ||
|
||
output "stdout" { | ||
value = step.container.tag_resources.stdout | ||
} | ||
|
||
output "stderr" { | ||
value = step.container.tag_resources.stderr | ||
} | ||
} |