'can't deploy chalice app as a non-root user :/

I have an AWS account with a non-root user given AdministratorAccess and AWSLambda_FullAccess.

I am using the template for a chalice app in app.py

from chalice import Chalice

app = Chalice(app_name='my_app')

@app.route('/')
def index():
    return {'hello': 'world'}

In an anaconda prompt I type

(mlenv) C:\Users\noms0\> cd my-app
(mlenv) C:\Users\noms0\my-app> chalice deploy

The output isn't pretty.

> ---------- Creating deployment package. Reusing existing deployment package. Traceback (most recent call last):   File
    > "C:\Users\noms0\anaconda3\envs\mlenv\lib\site-packages\chalice\deploy\deployer.py",
    > line 376, in deploy
    >     return self._deploy(config, chalice_stage_name)   File "C:\Users\noms0\anaconda3\envs\mlenv\lib\site-packages\chalice\deploy\deployer.py",
    > line 392, in _deploy
    >     plan = self._plan_stage.execute(resources) # bug   File "C:\Users\noms0\anaconda3\envs\mlenv\lib\site-packages\chalice\deploy\planner.py",
    > line 206, in execute
    >     result = handler(resource)   File "C:\Users\noms0\anaconda3\envs\mlenv\lib\site-packages\chalice\deploy\planner.py",
    > line 475, in _plan_lambdafunction
    >     if not self._remote_state.resource_exists(resource):   File "C:\Users\noms0\anaconda3\envs\mlenv\lib\site-packages\chalice\deploy\planner.py",
    > line 70, in resource_exists
    >     result = handler(resource, *args)   File "C:\Users\noms0\anaconda3\envs\mlenv\lib\site-packages\chalice\deploy\planner.py",
    > line 144, in _resource_exists_lambdafunction
    >     return self._client.lambda_function_exists(resource.function_name)   File
    > "C:\Users\noms0\anaconda3\envs\mlenv\lib\site-packages\chalice\awsclient.py",
    > line 261, in lambda_function_exists
    >     client.get_function(FunctionName=name)   File "C:\Users\noms0\anaconda3\envs\mlenv\lib\site-packages\botocore\client.py",
    > line 415, in _api_call
    >     return self._make_api_call(operation_name, kwargs)   File "C:\Users\noms0\anaconda3\envs\mlenv\lib\site-packages\botocore\client.py",
    > line 745, in _make_api_call
    >     raise error_class(parsed_response, operation_name) botocore.exceptions.ClientError: An error occurred
    > (AccessDeniedException) when calling the GetFunction operation: None
    > 
    > During handling of the above exception, another exception occurred:
    > 
    > Traceback (most recent call last):   File
    > "C:\Users\noms0\anaconda3\envs\mlenv\lib\site-packages\chalice\cli\__init__.py",
    > line 636, in main
    >     return cli(obj={})   File "C:\Users\noms0\anaconda3\envs\mlenv\lib\site-packages\click\core.py",
    > line 1128, in __call__
    >     return self.main(*args, **kwargs)   File "C:\Users\noms0\anaconda3\envs\mlenv\lib\site-packages\click\core.py",
    > line 1053, in main
    >     rv = self.invoke(ctx)   File "C:\Users\noms0\anaconda3\envs\mlenv\lib\site-packages\click\core.py",
    > line 1659, in invoke
    >     return _process_result(sub_ctx.command.invoke(sub_ctx))   File "C:\Users\noms0\anaconda3\envs\mlenv\lib\site-packages\click\core.py",
    > line 1395, in invoke
    >     return ctx.invoke(self.callback, **ctx.params)   File "C:\Users\noms0\anaconda3\envs\mlenv\lib\site-packages\click\core.py",
    > line 754, in invoke
    >     return __callback(*args, **kwargs)   File "C:\Users\noms0\anaconda3\envs\mlenv\lib\site-packages\click\decorators.py",
    > line 26, in new_func
    >     return f(get_current_context(), *args, **kwargs)   File "C:\Users\noms0\anaconda3\envs\mlenv\lib\site-packages\chalice\cli\__init__.py",
    > line 189, in deploy
    >     deployed_values = d.deploy(config, chalice_stage_name=stage)   File
    > "C:\Users\noms0\anaconda3\envs\mlenv\lib\site-packages\chalice\deploy\deployer.py",
    > line 378, in deploy
    >     raise ChaliceDeploymentError(e) chalice.deploy.deployer.ChaliceDeploymentError: ERROR - While
    > deploying your chalice application, received the following error:
    > 
    >  An error occurred (AccessDeniedException) when calling the
    > GetFunction  operation: None

When I go to chalice's deployer.py I find that the line giving the console trouble is

plan = self._plan_stage.execute(resources)

This app is very important to me but I can't seem to figure out the problem :(

Any help is welcome, thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source