Skip to content

Commit 0e0687f

Browse files
authored
Merge pull request #2 from rhythmictech/private-default
[ENG-897] make private by default, allow public
2 parents 1b5bff1 + 9754b8e commit 0e0687f

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

cloudformation.yml.tpl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@ Resources:
99
Distributions:
1010
%{~ for region in regions ~}
1111
- AmiDistributionConfiguration:
12-
Name: '${name} - AmiCopyConfiguration - {{ imagebuilder:buildDate }}'
12+
Name: '${name} - ${region} - AmiCopyConfiguration - {{ imagebuilder:buildDate }}'
1313
%{~ if description != null ~}
1414
Description: ${description}
1515
%{~ endif ~}
1616
AmiTags:
1717
${ indent(14, chomp(yamlencode(tags))) }
18-
%{~ if shared_account_ids != null ~}
1918
LaunchPermissionConfiguration:
19+
%{~ if public == false ~}
2020
UserIds:
21-
${ indent(14, chomp(yamlencode(shared_account_ids))) }
22-
%{~ endif ~}
21+
${ indent(16, chomp(yamlencode(shared_account_ids))) }
22+
%{~ else ~}
23+
UserGroups:
24+
- all
25+
%{~ endif ~}
2326
%{~ if license_config_arns != null ~}
2427
LicenseConfigurationArns:
2528
${ indent(12, chomp(yamlencode(license_config_arns)))}

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ resource "aws_cloudformation_stack" "this" {
9393
log_bucket = var.log_bucket
9494
log_prefix = var.log_prefix
9595
name = var.name
96+
public = var.public
9697
recipe_arn = var.recipe_arn
9798
regions = var.regions
9899
schedule = var.schedule

variables.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ variable "name" {
5757
type = string
5858
}
5959

60+
variable "public" {
61+
default = false
62+
description = "Whether resulting AMI should be public"
63+
type = bool
64+
}
65+
6066
variable "recipe_arn" {
6167
description = "ARN of the recipe to use. Must change with Recipe version"
6268
type = string
@@ -91,7 +97,7 @@ variable "security_group_ids" {
9197
}
9298

9399
variable "shared_account_ids" {
94-
default = null
100+
default = []
95101
description = "AWS accounts to share AMIs with. If this is left null AMIs will be public"
96102
type = list(string)
97103
}

0 commit comments

Comments
 (0)