Skip to content

Commit 62ab8f7

Browse files
author
Mike Saintcross
committed
added some input validation on variables
1 parent 4c6ffb9 commit 62ab8f7

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

recipes.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ resource "aws_imagebuilder_container_recipe" "container_image" {
99

1010
container_type = "DOCKER"
1111
parent_image = "amazonlinux:latest"
12-
working_directory = "/build"
12+
working_directory = "/tmp"
1313

1414
target_repository {
1515
repository_name = var.ecr_name
@@ -19,12 +19,12 @@ resource "aws_imagebuilder_container_recipe" "container_image" {
1919
instance_configuration {
2020

2121
block_device_mapping {
22-
device_name = "/dev/xvdb"
22+
device_name = "/dev/xvda"
2323

2424
ebs {
2525
delete_on_termination = true
2626
volume_size = var.ebs_root_vol_size
27-
volume_type = "gp3"
27+
volume_type = "gp2"
2828
encrypted = true
2929
kms_key_id = aws_kms_key.this.arn
3030
}

variables.tf

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ variable "aws_region" {
2626
type = string
2727
default = "us-east-1"
2828
description = "Enter the AWS Region you wish to deploy in."
29+
validation {
30+
condition = can(regex("(us(-gov)?|ap|ca|cn|eu|sa)-(central|(north|south)?(east|west)?)-\d", var.aws_region))
31+
error_message = "Enter a valid region."
32+
}
2933
}
3034

3135
variable "vpc_name" {
@@ -51,6 +55,10 @@ variable "ecr_name" {
5155
variable "aws_s3_ami_resources_bucket" {
5256
type = string
5357
description = "Enter the name for an S3 Bucket that will host all files necessary to build the pipeline and container images."
58+
validation {
59+
condition = substr(var.aws_s3_ami_resources_bucket, 0, 1) != "/" && substr(var.aws_s3_ami_resources_bucket, -1, 1) != "/" && length(var.aws_s3_ami_resources_bucket) > 0
60+
error_message = "Parameter `aws_s3_ami_resources_bucket` cannot start and end with \"/\", as well as cannot be empty."
61+
}
5462
}
5563

5664
variable "ebs_root_vol_size" {

0 commit comments

Comments
 (0)