diff --git a/s3-bucket/main.tf b/s3-bucket/main.tf new file mode 100644 index 0000000..aa910c7 --- /dev/null +++ b/s3-bucket/main.tf @@ -0,0 +1,14 @@ +variable "name" { + type = string +} + +resource "aws_s3_bucket" "cdevautotests" { + bucket = var.name + tags = { + Name = "Cdev auto tests bucket" + } +} + +output "id" { + value = aws_s3_bucket.cdevautotests.id +} diff --git a/s3-file/main.tf b/s3-file/main.tf new file mode 100644 index 0000000..11040f2 --- /dev/null +++ b/s3-file/main.tf @@ -0,0 +1,11 @@ +variable "bucket_name" { + type = string +} + +resource "aws_s3_bucket_object" "cdev_object" { + key = "s3file.txt" + bucket = var.bucket_name + source = "${path.module}/s3file.txt" + + force_destroy = true +} diff --git a/s3-file/s3file.txt b/s3-file/s3file.txt new file mode 100644 index 0000000..e49ea1f --- /dev/null +++ b/s3-file/s3file.txt @@ -0,0 +1 @@ +File will be uploaded to s3 bucket. \ No newline at end of file diff --git a/template.yaml b/template.yaml new file mode 100644 index 0000000..0ba8d23 --- /dev/null +++ b/template.yaml @@ -0,0 +1,25 @@ +name: cdev-tests +kind: InfraTemplate +modules: + - + name: create-bucket + type: terraform + source: github.com/shalb/cdev-test-template//s3-bucket/ + pre_hook: + command: echo "check cdev hook" + on_destroy: true + on_plan: true + inputs: + name: {{ .name }} + - + name: create-s3-object + type: terraform + source: ./s3-file/ + inputs: + bucket_name: {{ remoteState "this.create-bucket.id" }} + - + name: print_outputs + type: printer + depends_on: this.create-s3-object + inputs: + bucket_name: Bucket name is {{ remoteState "this.create-bucket.id" }}