Skip to content

Instantly share code, notes, and snippets.

@MattBlack85
Last active May 7, 2020 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattBlack85/a97a5e3b264f6e81ae18824995c550a7 to your computer and use it in GitHub Desktop.
Save MattBlack85/a97a5e3b264f6e81ae18824995c550a7 to your computer and use it in GitHub Desktop.
# helper function in helpers/ecs.py
from typing import Dict, List
from pulumi_aws import ecs
from configuration import STACK_ENV
from helpers.names.utils import create_unique_name
def setup_ecs_cluster(
project_name,
*,
capacity_providers: List[str] = None,
default_capacity_provider_strategies: List[Dict] = None,
):
"""
Creates an ECS cluster for a given project
"""
ECS_NAME = f'{create_unique_name(project_name)}-ecs'
ecs_cluster = ecs.Cluster(
ECS_NAME,
name=ECS_NAME,
capacity_providers=capacity_providers,
default_capacity_provider_strategies=default_capacity_provider_strategies,
tags={'env': STACK_ENV, 'Name': ECS_NAME, 'product': project_name},
)
return ecs_cluster
# test
import pulumi
class PulumiMock(pulumi.runtime.Mocks):
def new_resource(self, type_, name, inputs, provider, id_):
return [name + '_id', inputs]
def call(self, token, args, provider):
return {}
pulumi.runtime.set_mocks(PulumiMock())
from helpers.ecs import setup_ecs_cluster # isort: skip # NOQA
@pulumi.runtime.test
def test_ecs_cluster_creation_no_default_capacity_providers():
name = 'foo'
capacity_providers = ['bar']
cluster = setup_ecs_cluster(name, capacity_providers=capacity_providers)
def check(args):
print(args)
mocked_cluster = args
assert mocked_cluster.name == 'foo'
return cluster.apply(check)
# Traceback
Task exception was never retrieved
future: <Task finished name='Task-20' coro=<Output.future.<locals>.get_value() done, defined at /home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py:113> exception=AttributeError("'NoneType' object has no attribute 'get'")>
Traceback (most recent call last):
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 114, in get_value
val = await self._future
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 176, in run
transformed: Input[U] = func(value)
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/stack_reference.py", line 70, in <lambda>
value: Output[Any] = Output.all(Output.from_input(name), self.outputs).apply(lambda l: l[1].get(l[0])) # type: ignore
AttributeError: 'NoneType' object has no attribute 'get'
Task exception was never retrieved
future: <Task finished name='Task-35' coro=<Output.future.<locals>.get_value() done, defined at /home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py:113> exception=AttributeError("'NoneType' object has no attribute 'get'")>
Traceback (most recent call last):
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 114, in get_value
val = await self._future
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 176, in run
transformed: Input[U] = func(value)
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/stack_reference.py", line 70, in <lambda>
value: Output[Any] = Output.all(Output.from_input(name), self.outputs).apply(lambda l: l[1].get(l[0])) # type: ignore
AttributeError: 'NoneType' object has no attribute 'get'
Task exception was never retrieved
future: <Task finished name='Task-50' coro=<Output.future.<locals>.get_value() done, defined at /home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py:113> exception=AttributeError("'NoneType' object has no attribute 'get'")>
Traceback (most recent call last):
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 114, in get_value
val = await self._future
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 176, in run
transformed: Input[U] = func(value)
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/stack_reference.py", line 70, in <lambda>
value: Output[Any] = Output.all(Output.from_input(name), self.outputs).apply(lambda l: l[1].get(l[0])) # type: ignore
AttributeError: 'NoneType' object has no attribute 'get'
Task exception was never retrieved
future: <Task finished name='Task-101' coro=<Output.future.<locals>.get_value() done, defined at /home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py:113> exception=AttributeError("'NoneType' object has no attribute 'get'")>
Traceback (most recent call last):
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 114, in get_value
val = await self._future
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 176, in run
transformed: Input[U] = func(value)
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/stack_reference.py", line 70, in <lambda>
value: Output[Any] = Output.all(Output.from_input(name), self.outputs).apply(lambda l: l[1].get(l[0])) # type: ignore
AttributeError: 'NoneType' object has no attribute 'get'
Task exception was never retrieved
future: <Task finished name='Task-178' coro=<Output.apply.<locals>.run() done, defined at /home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py:149> exception=AttributeError("'NoneType' object has no attribute 'get'")>
Traceback (most recent call last):
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 155, in run
value = await self._future
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 340, in gather_futures
return await asyncio.gather(*value_futures)
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 114, in get_value
val = await self._future
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 155, in run
value = await self._future
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 155, in run
value = await self._future
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 114, in get_value
val = await self._future
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 176, in run
transformed: Input[U] = func(value)
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/stack_reference.py", line 70, in <lambda>
value: Output[Any] = Output.all(Output.from_input(name), self.outputs).apply(lambda l: l[1].get(l[0])) # type: ignore
AttributeError: 'NoneType' object has no attribute 'get'
Task exception was never retrieved
future: <Task finished name='Task-189' coro=<Output.apply.<locals>.run() done, defined at /home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py:149> exception=AttributeError("'NoneType' object has no attribute 'get'")>
Traceback (most recent call last):
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 155, in run
value = await self._future
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 340, in gather_futures
return await asyncio.gather(*value_futures)
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 114, in get_value
val = await self._future
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 155, in run
value = await self._future
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 155, in run
value = await self._future
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 114, in get_value
val = await self._future
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/output.py", line 176, in run
transformed: Input[U] = func(value)
File "/home/matt/.local/share/virtualenvs/cyclope-mw2Vtk-i/lib/python3.8/site-packages/pulumi/stack_reference.py", line 70, in <lambda>
value: Output[Any] = Output.all(Output.from_input(name), self.outputs).apply(lambda l: l[1].get(l[0])) # type: ignore
AttributeError: 'NoneType' object has no attribute 'get'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment