Beispiel #1
0
    def register_task_definition(self, task_definition: EcsTaskDefinition):
        if task_definition.tags:
            task_definition.additional_properties[
                'tags'] = task_definition.tags

        new_task_definition_payload = self._ecs.register_task_definition(
            family=task_definition.family,
            containerDefinitions=task_definition.containers,
            volumes=task_definition.volumes,
            taskRoleArn=task_definition.role_arn,
            executionRoleArn=task_definition.execution_role_arn,
            **task_definition.additional_properties)

        return EcsTaskDefinition(
            **new_task_definition_payload['taskDefinition'])
Beispiel #2
0
def test_client_register_task_definition_without_tags(client):
    containers = [{u'name': u'foo'}]
    volumes = [{u'foo': u'bar'}]
    role_arn = 'arn:test:role'
    execution_role_arn = 'arn:test:role'
    task_definition = EcsTaskDefinition(containerDefinitions=containers,
                                        volumes=volumes,
                                        family=u'family',
                                        revision=1,
                                        taskRoleArn=role_arn,
                                        executionRoleArn=execution_role_arn,
                                        tags={},
                                        status='active',
                                        taskDefinitionArn='arn:task',
                                        requiresAttributes={},
                                        unkownProperty='foobar')

    client.register_task_definition(
        family=task_definition.family,
        containers=task_definition.containers,
        volumes=task_definition.volumes,
        role_arn=task_definition.role_arn,
        execution_role_arn=execution_role_arn,
        tags=task_definition.tags,
        additional_properties=task_definition.additional_properties)

    client.boto.register_task_definition.assert_called_once_with(
        family=u'family',
        containerDefinitions=containers,
        volumes=volumes,
        taskRoleArn=role_arn,
        executionRoleArn=execution_role_arn,
        unkownProperty='foobar')
Beispiel #3
0
    def get_task_definition(self, task_definition_arn: str):
        if not self.access_key_id or not self.secret_access_key:
            raise CodeDeployConnectionError('Unable to locate credentials')

        if task_definition_arn != 'arn:aws:ecs:eu-west-1:123456789012:task-definition/test-task:1':
            raise UnknownTaskDefinitionError(
                'An error occurred (ClientException) when calling the DescribeTaskDefinition operation: Unable to describe task definition.')  # noqa: E501

        task_definition_payload = TASK_DEFINITION_PAYLOAD

        return EcsTaskDefinition(
            tags=task_definition_payload.get('tags', None), **task_definition_payload['taskDefinition']
        )
Beispiel #4
0
    def get_task_definition(self,
                            task_definition_arn: str) -> EcsTaskDefinition:
        try:
            task_definition_payload = self._ecs.describe_task_definition(
                taskDefinition=task_definition_arn, include=[
                    'TAGS',
                ])

            return EcsTaskDefinition(
                tags=task_definition_payload.get('tags', None),
                **task_definition_payload['taskDefinition'])
        except ClientError as e:
            raise UnknownTaskDefinitionError(str(e))
Beispiel #5
0
def task_definition_revision_2():
    return EcsTaskDefinition(**deepcopy(PAYLOAD_TASK_DEFINITION_2))
Beispiel #6
0
def task_definition():
    return EcsTaskDefinition(**deepcopy(PAYLOAD_TASK_DEFINITION_1))