-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: fnsub not working for repo * fix: escape : char * fix: escape : char (2) * fix: need to use FnJoin because if tag_param is there then it will use Ref * fix: spec files
- Loading branch information
1 parent
e8e8ca3
commit 2cd8b4a
Showing
9 changed files
with
425 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
require 'yaml' | ||
|
||
describe 'compiled component ecs-task' do | ||
|
||
context 'cftest' do | ||
it 'compiles test' do | ||
expect(system("cfhighlander cftest #{@validate} --tests tests/depends_on.test.yaml")).to be_truthy | ||
end | ||
end | ||
|
||
let(:template) { YAML.load_file("#{File.dirname(__FILE__)}/../out/tests/depends_on/ecs-task.compiled.yaml") } | ||
|
||
context "Resource" do | ||
|
||
|
||
context "LogGroup" do | ||
let(:resource) { template["Resources"]["LogGroup"] } | ||
|
||
it "is of type AWS::Logs::LogGroup" do | ||
expect(resource["Type"]).to eq("AWS::Logs::LogGroup") | ||
end | ||
|
||
it "to have property LogGroupName" do | ||
expect(resource["Properties"]["LogGroupName"]).to eq({"Ref"=>"AWS::StackName"}) | ||
end | ||
|
||
it "to have property RetentionInDays" do | ||
expect(resource["Properties"]["RetentionInDays"]).to eq(7) | ||
end | ||
|
||
end | ||
|
||
context "Task" do | ||
let(:resource) { template["Resources"]["Task"] } | ||
|
||
it "is of type AWS::ECS::TaskDefinition" do | ||
expect(resource["Type"]).to eq("AWS::ECS::TaskDefinition") | ||
end | ||
|
||
it "to have property ContainerDefinitions" do | ||
expect(resource["Properties"]["ContainerDefinitions"]).to eq([{"Name"=>"nginx", "Image"=>{"Fn::Join"=>["", [{"Fn::Sub"=>"nginx/nginx"}, ":", "latest"]]}, "LogConfiguration"=>{"LogDriver"=>"awslogs", "Options"=>{"awslogs-group"=>{"Ref"=>"LogGroup"}, "awslogs-region"=>{"Ref"=>"AWS::Region"}, "awslogs-stream-prefix"=>"nginx"}}, "DependsOn"=>[{"ContainerName"=>"db", "Condition"=>"START"}]}, {"Name"=>"db", "Image"=>{"Fn::Join"=>["", [{"Fn::Sub"=>"/postgres"}, ":", "latest"]]}, "LogConfiguration"=>{"LogDriver"=>"awslogs", "Options"=>{"awslogs-group"=>{"Ref"=>"LogGroup"}, "awslogs-region"=>{"Ref"=>"AWS::Region"}, "awslogs-stream-prefix"=>"db"}}, "Essential"=>false, "PortMappings"=>[{"ContainerPort"=>5432}]}]) | ||
end | ||
|
||
it "to have property RequiresCompatibilities" do | ||
expect(resource["Properties"]["RequiresCompatibilities"]).to eq(["EC2"]) | ||
end | ||
|
||
it "to have property Tags" do | ||
expect(resource["Properties"]["Tags"]).to eq([{"Key"=>"Name", "Value"=>"ecs-task"}, {"Key"=>"Environment", "Value"=>{"Ref"=>"EnvironmentName"}}, {"Key"=>"EnvironmentType", "Value"=>{"Ref"=>"EnvironmentType"}}]) | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
require 'yaml' | ||
|
||
describe 'compiled component ecs-task' do | ||
|
||
context 'cftest' do | ||
it 'compiles test' do | ||
expect(system("cfhighlander cftest #{@validate} --tests tests/ecs-exec.test.yaml")).to be_truthy | ||
end | ||
end | ||
|
||
let(:template) { YAML.load_file("#{File.dirname(__FILE__)}/../out/tests/ecs-exec/ecs-task.compiled.yaml") } | ||
|
||
context "Resource" do | ||
|
||
|
||
context "LogGroup" do | ||
let(:resource) { template["Resources"]["LogGroup"] } | ||
|
||
it "is of type AWS::Logs::LogGroup" do | ||
expect(resource["Type"]).to eq("AWS::Logs::LogGroup") | ||
end | ||
|
||
it "to have property LogGroupName" do | ||
expect(resource["Properties"]["LogGroupName"]).to eq({"Ref"=>"AWS::StackName"}) | ||
end | ||
|
||
it "to have property RetentionInDays" do | ||
expect(resource["Properties"]["RetentionInDays"]).to eq(7) | ||
end | ||
|
||
end | ||
|
||
context "TaskRole" do | ||
let(:resource) { template["Resources"]["TaskRole"] } | ||
|
||
it "is of type AWS::IAM::Role" do | ||
expect(resource["Type"]).to eq("AWS::IAM::Role") | ||
end | ||
|
||
it "to have property AssumeRolePolicyDocument" do | ||
expect(resource["Properties"]["AssumeRolePolicyDocument"]).to eq({"Version"=>"2012-10-17", "Statement"=>[{"Effect"=>"Allow", "Principal"=>{"Service"=>"ecs-tasks.amazonaws.com"}, "Action"=>"sts:AssumeRole"}, {"Effect"=>"Allow", "Principal"=>{"Service"=>"ssm.amazonaws.com"}, "Action"=>"sts:AssumeRole"}]}) | ||
end | ||
|
||
it "to have property Path" do | ||
expect(resource["Properties"]["Path"]).to eq("/") | ||
end | ||
|
||
it "to have property Policies" do | ||
expect(resource["Properties"]["Policies"]).to eq([{"PolicyName"=>"ssm-session-manager", "PolicyDocument"=>{"Version"=>"2012-10-17", "Statement"=>[{"Sid"=>"ssmsessionmanager", "Action"=>["ssmmessages:CreateControlChannel", "ssmmessages:CreateDataChannel", "ssmmessages:OpenControlChannel", "ssmmessages:OpenDataChannel"], "Resource"=>["*"], "Effect"=>"Allow"}]}}]) | ||
end | ||
|
||
end | ||
|
||
context "ExecutionRole" do | ||
let(:resource) { template["Resources"]["ExecutionRole"] } | ||
|
||
it "is of type AWS::IAM::Role" do | ||
expect(resource["Type"]).to eq("AWS::IAM::Role") | ||
end | ||
|
||
it "to have property AssumeRolePolicyDocument" do | ||
expect(resource["Properties"]["AssumeRolePolicyDocument"]).to eq({"Version"=>"2012-10-17", "Statement"=>[{"Effect"=>"Allow", "Principal"=>{"Service"=>"ecs-tasks.amazonaws.com"}, "Action"=>"sts:AssumeRole"}, {"Effect"=>"Allow", "Principal"=>{"Service"=>"ssm.amazonaws.com"}, "Action"=>"sts:AssumeRole"}]}) | ||
end | ||
|
||
it "to have property Path" do | ||
expect(resource["Properties"]["Path"]).to eq("/") | ||
end | ||
|
||
it "to have property ManagedPolicyArns" do | ||
expect(resource["Properties"]["ManagedPolicyArns"]).to eq(["arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"]) | ||
end | ||
|
||
end | ||
|
||
context "Task" do | ||
let(:resource) { template["Resources"]["Task"] } | ||
|
||
it "is of type AWS::ECS::TaskDefinition" do | ||
expect(resource["Type"]).to eq("AWS::ECS::TaskDefinition") | ||
end | ||
|
||
it "to have property ContainerDefinitions" do | ||
expect(resource["Properties"]["ContainerDefinitions"]).to eq([{"Name"=>"schema", "Image"=>{"Fn::Join"=>["", [{"Fn::Sub"=>"myrepo/backend"}, ":", {"Ref"=>"SchemaTag"}]]}, "LogConfiguration"=>{"LogDriver"=>"awslogs", "Options"=>{"awslogs-group"=>{"Ref"=>"LogGroup"}, "awslogs-region"=>{"Ref"=>"AWS::Region"}, "awslogs-stream-prefix"=>"schema"}}}]) | ||
end | ||
|
||
it "to have property RequiresCompatibilities" do | ||
expect(resource["Properties"]["RequiresCompatibilities"]).to eq(["FARGATE"]) | ||
end | ||
|
||
it "to have property Cpu" do | ||
expect(resource["Properties"]["Cpu"]).to eq(256) | ||
end | ||
|
||
it "to have property Memory" do | ||
expect(resource["Properties"]["Memory"]).to eq(512) | ||
end | ||
|
||
it "to have property NetworkMode" do | ||
expect(resource["Properties"]["NetworkMode"]).to eq("awsvpc") | ||
end | ||
|
||
it "to have property TaskRoleArn" do | ||
expect(resource["Properties"]["TaskRoleArn"]).to eq({"Ref"=>"TaskRole"}) | ||
end | ||
|
||
it "to have property ExecutionRoleArn" do | ||
expect(resource["Properties"]["ExecutionRoleArn"]).to eq({"Ref"=>"ExecutionRole"}) | ||
end | ||
|
||
it "to have property Tags" do | ||
expect(resource["Properties"]["Tags"]).to eq([{"Key"=>"Name", "Value"=>"ecs-task"}, {"Key"=>"Environment", "Value"=>{"Ref"=>"EnvironmentName"}}, {"Key"=>"EnvironmentType", "Value"=>{"Ref"=>"EnvironmentType"}}]) | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end |
Oops, something went wrong.