Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inf-terraform-aws: remove cloudformation stack from default quickstarter #934

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- Add binutils to jdk agent ([929](https://github.com/opendevstack/ods-quickstarters/issues/929))
- Change golden tests to be able to execute them in other namespaces ([933](https://github.com/opendevstack/ods-quickstarters/pull/933))
- inf-terraform-[aws], switch from shared statefile location to dedicated bucket ([#900](https://github.com/opendevstack/ods-quickstarters/issues/900))
- inf-terraform-[aws], remove Cloudformation exampe from quickstarter ([#934](https://github.com/opendevstack/ods-quickstarters/pull/934))

## [4.1] - 2022-11-17

Expand Down
29 changes: 0 additions & 29 deletions inf-terraform-aws/files/cfn-templates/cfs3.json

This file was deleted.

1 change: 0 additions & 1 deletion inf-terraform-aws/files/inputs2outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
output "inputs2outputs" {
description = "all inputs passed to outputs"
value = [{
data_bucket_name = var.data_bucket_name
meta_environment = var.meta_environment
name = var.name
}]
Expand Down
9 changes: 1 addition & 8 deletions inf-terraform-aws/files/main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
locals {
unique_name = var.name

cf_stack_name = "cft-s3"

tags = merge(local.common_tags, {
DeploymentDate = formatdate("YYYYMMDD", timestamp())
InitialDeploymentDate = time_static.deployment.rfc3339
Expand All @@ -11,10 +9,5 @@ locals {

resource "time_static" "deployment" {}

resource "aws_cloudformation_stack" "cft-s3" {
name = var.name
template_body = file("${path.module}/cfn-templates/cfs3.json")
tags = local.tags
}

data "aws_region" "current" {}

5 changes: 5 additions & 0 deletions inf-terraform-aws/files/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ output "meta_environment" {
description = "The type of the environment."
value = var.meta_environment
}

output "aws_region" {
description = "The current region."
value = data.aws_region.current.name
}
9 changes: 4 additions & 5 deletions inf-terraform-aws/files/terraform-data.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
locals {
terraform-data = {
id = local.id
name = var.name
tags = local.tags
data_bucket_name = var.data_bucket_name
cf_stack_outputs = aws_cloudformation_stack.cft-s3.outputs
id = local.id
name = var.name
tags = local.tags
current_region = data.aws_region.current.name
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,8 @@
desc "This test suite asserts the correct functionality of the stack under test."
tag name

cfClient = SpecHelper::AWS.sdk.client(Aws::CloudFormation)
cfStackName = name

# ###########################################################
# Test if Cloudformation Stack has been succesfully deployed
# ###########################################################
describe "CloudFormation Stack #{cfStackName}" do
cfStack = cfClient.describe_stacks({ stack_name: cfStackName }).stacks[0]

context 'status' do
it { expect(cfStack.stack_status).to eq("CREATE_COMPLETE").or eq("UPDATE_COMPLETE") }
end
end

cfStackOutputs = t['cf_stack_outputs']
cfStackOutputsHash = cfStackOutputs.to_h
s3BucketName = cfStackOutputsHash["S3BucketName"]

# ###########################################################
# Tests on resources deployed by the Cloudformation Stack
# ###########################################################
describe aws_s3_bucket(bucket_name: s3BucketName) do
it { should exist }
it { should_not be_public }
its('bucket_policy') { should be_empty }
its('region') { should eq 'eu-west-1' }
it { should have_default_encryption_enabled }
describe aws_region(region_name: t['current_region']) do
its('endpoint') { should be_in ['ec2.eu-west-1.amazonaws.com','ec2.us-east-1.amazonaws.com'] }
end

describe "Stack Testing" do
Expand Down
10 changes: 0 additions & 10 deletions inf-terraform-aws/files/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,3 @@ variable "meta_environment" {
default = "DEVELOPMENT"
}

# ---------------------------------------------
# S3 Bucket Variables
# ---------------------------------------------

variable "data_bucket_name" {
description = "The name of the S3 data bucket."
type = string
default = "quickstarter"
}