Skip to content

Commit

Permalink
Merge pull request #26 from Guslington/develop
Browse files Browse the repository at this point in the history
create config tests, replace az function with list of subnetIds parameter
  • Loading branch information
Guslington authored May 29, 2019
2 parents 29e3959 + 983f0f1 commit 67046d4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 12 deletions.
11 changes: 8 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@

language: ruby
rvm:
- 2.3
- 2.5
install:
- gem install cfhighlander cfn-nag
before_script:
- cfndsl -u 2.21.0
script:
- gem install cfhighlander --prerelease
- if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then cfhighlander cfcompile ; else cfhighlander cfcompile --validate; fi
- if [ "${TRAVIS_PULL_REQUEST}" != "false" ]; then cfhighlander cftest --no-validate; else cfhighlander cftest; fi
- cfn_nag_scan -i out/tests
6 changes: 2 additions & 4 deletions ecs-service.cfhighlander.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
CfhighlanderTemplate do

DependsOn 'vpc@1.2.0' if ((defined? network_mode) && (network_mode == "awsvpc"))
DependsOn 'vpc' if ((defined? network_mode) && (network_mode == "awsvpc"))

Description "ecs-service - #{component_name} - #{component_version}"

Expand All @@ -27,9 +27,7 @@
ComponentParam 'EnableScaling', 'false', allowedValues: ['true','false']

if ((defined? network_mode) && (network_mode == "awsvpc"))
maximum_availability_zones.times do |az|
ComponentParam "SubnetCompute#{az}"
end
ComponentParam 'SubnetIds', type: 'CommaDelimitedList'
ComponentParam 'SecurityGroupBackplane'
end

Expand Down
6 changes: 1 addition & 5 deletions ecs-service.cfndsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
awsvpc_enabled = true
end

if awsvpc_enabled
az_conditions_resources('SubnetCompute', maximum_availability_zones)
end

Condition('IsScalingEnabled', FnEquals(Ref('EnableScaling'), 'true'))

log_retention = 7 unless defined?(log_retention)
Expand Down Expand Up @@ -340,7 +336,7 @@
AwsvpcConfiguration: {
AssignPublicIp: "DISABLED",
SecurityGroups: [ Ref(sg_name) ],
Subnets: az_conditional_resources('SubnetCompute', maximum_availability_zones)
Subnets: Ref('SubnetIds')
}
})
end
Expand Down
4 changes: 4 additions & 0 deletions tests/default.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test_metadata:
type: config
name: default
description: test with default config
19 changes: 19 additions & 0 deletions tests/nginx-service.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
test_metadata:
type: config
name: nginx
description: create a nginx ecs service with a targetgroup

task_definition:
nginx:
repo: nginx
image: nginx

targetgroup:
name: nginx
container: nginx
port: 80
protocol: http
listener: http
healthcheck:
path: /
code: 200

0 comments on commit 67046d4

Please sign in to comment.