Skip to content

Commit 15650cd

Browse files
committed
updates for PR feedback
1 parent ad626b7 commit 15650cd

File tree

8 files changed

+41
-42
lines changed

8 files changed

+41
-42
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
# .tfvars files
99
*.tfvars
10-
!example/*.tfvars
10+
!example/**/*.tfvars
1111

1212
# pem files
1313
*.pem

cloudformation.yml.tpl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ Resources:
1515
%{~ endif ~}
1616
AmiTags:
1717
${ indent(14, chomp(yamlencode(tags))) }
18-
%{~ if shared_accounts != null ~}
18+
%{~ if shared_account_ids != null ~}
1919
LaunchPermissionConfiguration:
2020
UserIds:
21-
${ indent(14, chomp(yamlencode(shared_accounts))) }
21+
${ indent(14, chomp(yamlencode(shared_account_ids))) }
2222
%{~ endif ~}
2323
%{~ if license_config_arns != null ~}
2424
LicenseConfigurationArns:
@@ -51,12 +51,12 @@ Resources:
5151
S3KeyPrefix: ${log_prefix}
5252
%{~ endif ~}
5353
%{~ endif ~}
54-
%{~ if security_groups != null ~}
54+
%{~ if security_group_ids != null ~}
5555
SecurityGroupIds:
56-
${ indent(8, chomp(yamlencode(security_groups))) }
56+
${ indent(8, chomp(yamlencode(security_group_ids))) }
5757
%{~ endif ~}
58-
%{~ if sns_topic != null ~}
59-
SnsTopicArn: ${sns_topic}
58+
%{~ if sns_topic_arn != null ~}
59+
SnsTopicArn: ${sns_topic_arn}
6060
%{~ endif ~}
6161
%{~ if subnet != null ~}
6262
SubnetId: ${subnet}

example/main.tf renamed to example/basic/main.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module "tags" {
2222
}, var.additional_tags)
2323
}
2424

25-
module "test-component" {
25+
module "test_component" {
2626
source = "git::https://github.com/rhythmictech/terraform-aws-imagebuilder-component-ansible.git?ref=init"
2727

2828
component_version = "1.0.0"
@@ -33,7 +33,7 @@ module "test-component" {
3333
tags = local.tags
3434
}
3535

36-
module "test-recipe" {
36+
module "test_recipe" {
3737
source = "git::https://github.com/rhythmictech/terraform-aws-imagebuilder-recipe.git?ref=init"
3838

3939
description = "Testing recipe"
@@ -43,18 +43,18 @@ module "test-recipe" {
4343
tags = local.tags
4444
update = true
4545

46-
components = [
47-
module.test-component.component_arn,
46+
component_arns = [
47+
module.test_component.component_arn,
4848
"arn:aws:imagebuilder:us-east-1:aws:component/simple-boot-test-linux/1.0.0/1",
4949
"arn:aws:imagebuilder:us-east-1:aws:component/reboot-test-linux/1.0.0/1"
5050
]
5151
}
5252

53-
module "test-pipeline" {
54-
source = "git::https://github.com/rhythmictech/terraform-aws-imagebuilder-pipeline.git?ref=init"
53+
module "test_pipeline" {
54+
source = "../../"
5555

5656
description = "Testing pipeline"
5757
name = "test-pipeline"
5858
tags = local.tags
59-
recipe_arn = module.test-recipe.recipe_arn
59+
recipe_arn = module.test_recipe.recipe_arn
6060
}

main.tf

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ resource "aws_iam_role" "this" {
3535
resource "aws_iam_role_policy_attachment" "this" {
3636
count = length(local.iam_policies)
3737

38-
role = aws_iam_role.this.name
3938
policy_arn = local.iam_policies[count.index]
39+
role = aws_iam_role.this.name
4040
}
4141

4242
resource "aws_iam_instance_profile" "this" {
@@ -47,7 +47,12 @@ resource "aws_iam_instance_profile" "this" {
4747
resource "aws_cloudformation_stack" "this" {
4848
name = var.name
4949
on_failure = "ROLLBACK"
50-
timeout_in_minutes = var.timeout
50+
timeout_in_minutes = var.cloudformation_timeout
51+
52+
tags = merge(
53+
var.tags,
54+
{ Name : "${var.name}-stack" }
55+
)
5156

5257
template_body = templatefile("${path.module}/cloudformation.yml.tpl", {
5358
description = var.description
@@ -61,10 +66,10 @@ resource "aws_cloudformation_stack" "this" {
6166
recipe_arn = var.recipe_arn
6267
regions = var.regions
6368
schedule = var.schedule
64-
security_groups = var.security_groups
65-
shared_accounts = var.shared_accounts
66-
sns_topic = var.sns_topic
67-
status = var.status
69+
security_group_ids = var.security_group_ids
70+
shared_account_ids = var.shared_account_ids
71+
sns_topic_arn = var.sns_topic_arn
72+
status = var.enabled ? "ENABLED" : "DISABLED"
6873
subnet = var.subnet
6974
terminate_on_failure = var.terminate_on_failure
7075
test_config = var.test_config
@@ -74,9 +79,4 @@ resource "aws_cloudformation_stack" "this" {
7479
{ Name : var.name }
7580
)
7681
})
77-
78-
tags = merge(
79-
var.tags,
80-
{ Name : "${var.name}-stack" }
81-
)
8282
}

variables.tf

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,24 @@ variable "additional_iam_policy_arns" {
44
type = list(string)
55
}
66

7+
variable "cloudformation_timeout" {
8+
default = 10
9+
description = "How long to wait (in minutes) for CFN to apply before giving up"
10+
type = number
11+
}
12+
713
variable "description" {
814
default = null
915
description = "description of component"
1016
type = string
1117
}
1218

19+
variable "enabled" {
20+
default = true
21+
description = "Whether pipeline is ENABLED or DISABLED"
22+
type = bool
23+
}
24+
1325
variable "instance_types" {
1426
default = ["t3.medium"]
1527
description = "Instance types to create images from. It's unclear why this is a list. Possibly because different types can result in different images (like ARM instances)"
@@ -72,31 +84,24 @@ variable "schedule" {
7284
})
7385
}
7486

75-
variable "security_groups" {
87+
variable "security_group_ids" {
7688
default = null
77-
description = "Security groups for the Image Builder"
89+
description = "Security group IDs for the Image Builder"
7890
type = list(string)
7991
}
8092

81-
variable "shared_accounts" {
93+
variable "shared_account_ids" {
8294
default = null
8395
description = "AWS accounts to share AMIs with. If this is left null AMIs will be public"
8496
type = list(string)
8597
}
8698

87-
variable "sns_topic" {
99+
variable "sns_topic_arn" {
88100
default = null
89101
description = "SNS topic to notify when new images are created"
90102
type = string
91103
}
92104

93-
# TODO: Add validation
94-
variable "status" {
95-
default = "ENABLED"
96-
description = "Whether pipeline is ENABLED or DISABLED"
97-
type = string
98-
}
99-
100105
variable "subnet" {
101106
default = null
102107
description = "Subnet ID to use for builder"
@@ -126,9 +131,3 @@ variable "test_config" {
126131
TimeoutMinutes = number
127132
})
128133
}
129-
130-
variable "timeout" {
131-
default = 10
132-
description = "How long to wait (in minutes) for CFN to apply before giving up"
133-
type = number
134-
}

0 commit comments

Comments
 (0)