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

Added explicit environment to role #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion cloudlift/deployment/service_template_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def _add_service(self, service_name, config):
cd = ContainerDefinition(**container_definition_arguments)

task_role = self.template.add_resource(Role(
service_name + "Role",
pascalcase(self.env + service_name + "Role"),
AssumeRolePolicyDocument=PolicyDocument(
Statement=[
Statement(
Expand Down
2 changes: 1 addition & 1 deletion cloudlift/version/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '1.4.3'
VERSION = '1.4.4'
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
boto3>=1.9.89
boto3>=1.13.1
awscli
certifi==2017.7.27.1
cfn-flip==1.0.3
Expand Down
52 changes: 26 additions & 26 deletions test/templates/expected_fargate_service_template.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Outputs:
CloudliftOptions:
Description: Options used with cloudlift when building this service
Value: '{"cloudlift_version": "1.4.3", "services": {"DummyFargateRunSidekiqsh": {"command": null, "fargate": {"cpu": 256, "memory": 512}, "memory_reservation": 512}, "DummyFargateService": {"command": null, "fargate": {"cpu": 256, "memory": 512}, "http_interface": {"container_port": 80, "internal": false, "restrict_access_to": ["0.0.0.0/0"], "health_check_path": "/elb-check"}, "memory_reservation": 512}}}'
Value: '{"cloudlift_version": "1.4.4", "services": {"DummyFargateRunSidekiqsh": {"command": null, "fargate": {"cpu": 256, "memory": 512}, "memory_reservation": 512}, "DummyFargateService": {"command": null, "fargate": {"cpu": 256, "memory": 512}, "http_interface": {"container_port": 80, "internal": false, "restrict_access_to": ["0.0.0.0/0"], "health_check_path": "/elb-check"}, "memory_reservation": 512}}}'
DummyFargateRunSidekiqshEcsServiceName:
Description: The ECS name which needs to be entered
Value: !GetAtt 'DummyFargateRunSidekiqsh.Name'
Expand Down Expand Up @@ -78,17 +78,6 @@ Resources:
- !Ref 'PrivateSubnet2'
TaskDefinition: !Ref 'DummyFargateRunSidekiqshTaskDefinition'
Type: AWS::ECS::Service
DummyFargateRunSidekiqshRole:
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- ecs-tasks.amazonaws.com
Type: AWS::IAM::Role
DummyFargateRunSidekiqshTaskDefinition:
Properties:
ContainerDefinitions:
Expand All @@ -113,7 +102,7 @@ Resources:
NetworkMode: awsvpc
RequiresCompatibilities:
- FARGATE
TaskRoleArn: !Ref 'DummyFargateRunSidekiqshRole'
TaskRoleArn: !Ref 'stagingDummyFargateRunSidekiqshRole'
Type: AWS::ECS::TaskDefinition
DummyFargateService:
DependsOn: SslLoadBalancerListenerDummyFargateService
Expand All @@ -134,17 +123,6 @@ Resources:
- !Ref 'PrivateSubnet2'
TaskDefinition: !Ref 'DummyFargateServiceTaskDefinition'
Type: AWS::ECS::Service
DummyFargateServiceRole:
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- ecs-tasks.amazonaws.com
Type: AWS::IAM::Role
DummyFargateServiceTaskDefinition:
Properties:
ContainerDefinitions:
Expand All @@ -171,7 +149,7 @@ Resources:
NetworkMode: awsvpc
RequiresCompatibilities:
- FARGATE
TaskRoleArn: !Ref 'DummyFargateServiceRole'
TaskRoleArn: !Ref 'stagingDummyFargateServiceRole'
Type: AWS::ECS::TaskDefinition
ECSServiceRole:
Properties:
Expand Down Expand Up @@ -447,4 +425,26 @@ Resources:
TargetType: ip
UnhealthyThresholdCount: 3
VpcId: !Ref 'VPC'
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Type: AWS::ElasticLoadBalancingV2::TargetGroup
stagingDummyFargateRunSidekiqshRole:
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- ecs-tasks.amazonaws.com
Type: AWS::IAM::Role
stagingDummyFargateServiceRole:
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- ecs-tasks.amazonaws.com
Type: AWS::IAM::Role
54 changes: 27 additions & 27 deletions test/templates/expected_service_template.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Outputs:
CloudliftOptions:
Description: Options used with cloudlift when building this service
Value: '{"cloudlift_version": "1.4.3", "services": {"Dummy": {"memory_reservation": 1000, "command": null, "http_interface": {"internal": false, "container_port": 7003, "restrict_access_to": ["0.0.0.0/0"], "health_check_path": "/elb-check"}}, "DummyRunSidekiqsh": {"memory_reservation": 1000, "command": "./run-sidekiq.sh"}}}'
Value: '{"cloudlift_version": "1.4.4", "services": {"Dummy": {"memory_reservation": 1000, "command": null, "http_interface": {"internal": false, "container_port": 7003, "restrict_access_to": ["0.0.0.0/0"], "health_check_path": "/elb-check"}}, "DummyRunSidekiqsh": {"memory_reservation": 1000, "command": "./run-sidekiq.sh"}}}'
DummyEcsServiceName:
Description: 'The ECS name which needs to be entered'
Value: !GetAtt 'Dummy.Name'
Expand Down Expand Up @@ -65,7 +65,7 @@ Resources:
DependsOn: SslLoadBalancerListenerDummy
Properties:
Cluster: cluster-staging
DesiredCount: 1
DesiredCount: 0
LaunchType: 'EC2'
LoadBalancers:
- ContainerName: DummyContainer
Expand All @@ -79,17 +79,6 @@ Resources:
Role: !Ref 'ECSServiceRole'
TaskDefinition: !Ref 'DummyTaskDefinition'
Type: AWS::ECS::Service
DummyRole:
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- ecs-tasks.amazonaws.com
Type: AWS::IAM::Role
DummyRunSidekiqsh:
Properties:
Cluster: cluster-staging
Expand All @@ -105,17 +94,6 @@ Resources:
Type: spread
TaskDefinition: !Ref 'DummyRunSidekiqshTaskDefinition'
Type: AWS::ECS::Service
DummyRunSidekiqshRole:
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- ecs-tasks.amazonaws.com
Type: AWS::IAM::Role
DummyRunSidekiqshTaskDefinition:
Properties:
ContainerDefinitions:
Expand All @@ -136,7 +114,7 @@ Resources:
MemoryReservation: 1000
Name: DummyRunSidekiqshContainer
Family: DummyRunSidekiqshFamily
TaskRoleArn: !Ref 'DummyRunSidekiqshRole'
TaskRoleArn: !Ref 'stagingDummyRunSidekiqshRole'
Type: AWS::ECS::TaskDefinition
DummyTaskDefinition:
Properties:
Expand All @@ -158,7 +136,7 @@ Resources:
PortMappings:
- ContainerPort: 7003
Family: DummyFamily
TaskRoleArn: !Ref 'DummyRole'
TaskRoleArn: !Ref 'stagingDummyRole'
Type: AWS::ECS::TaskDefinition
ECSServiceRole:
Properties:
Expand Down Expand Up @@ -415,4 +393,26 @@ Resources:
Value: '30'
UnhealthyThresholdCount: 3
VpcId: !Ref 'VPC'
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Type: AWS::ElasticLoadBalancingV2::TargetGroup
stagingDummyRole:
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- ecs-tasks.amazonaws.com
Type: AWS::IAM::Role
stagingDummyRunSidekiqshRole:
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- ecs-tasks.amazonaws.com
Type: AWS::IAM::Role
2 changes: 1 addition & 1 deletion test/test_cloudlift.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def mocked_fargate_service_config(cls, *args, **kwargs):

environment_name = 'staging'
service_name = 'dummy'
fargate_service_name = 'dummy-fargate'
fargate_service_name = f'{service_name}-fargate'

def test_cloudlift_can_deploy_to_ec2(keep_resources):
cfn_client = boto3.client('cloudformation')
Expand Down