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

Lambda hook breaks if no bucket is defined in the options or in the config #672

Open
danielkza opened this issue Oct 22, 2018 · 0 comments

Comments

@danielkza
Copy link
Contributor

It's possible to have no S3 bucket available if none is specified in the hook options, and the config deliberately sets stacker_bucket to the empty string.

The Lambda hook needs to check for that condition and fail with an explanatory error message instead of blowing up:

[2018-10-22T20:49:14] lambda: using default bucket from stacker: None
[2018-10-22T20:49:14] Method stacker.hooks.aws_lambda.upload_lambda_functions threw an exception:
Traceback (most recent call last):
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/stacker/util.py", line 403, in handle_hooks
    result = method(context=context, provider=provider, **kwargs)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/stacker/hooks/aws_lambda.py", line 501, in upload_lambda_functions
    ensure_s3_bucket(s3_client, bucket_name, bucket_region)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/stacker/util.py", line 514, in ensure_s3_bucket
    s3_client.head_bucket(Bucket=bucket_name)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/botocore/client.py", line 314, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/botocore/client.py", line 586, in _make_api_call
    api_params, operation_model, context=request_context)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/botocore/client.py", line 619, in _convert_to_request_dict
    api_params, operation_model, context)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/botocore/client.py", line 648, in _emit_api_params
    params=api_params, model=operation_model, context=context)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/botocore/hooks.py", line 227, in emit
    return self._emit(event_name, kwargs)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/botocore/hooks.py", line 210, in _emit
    response = handler(**kwargs)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/botocore/handlers.py", line 217, in validate_bucket_name
    if VALID_BUCKET.search(bucket) is None:
TypeError: expected string or buffer
Traceback (most recent call last):
  File "/usr/lib64/python2.7/pdb.py", line 1314, in main
    pdb._runscript(mainpyfile)
  File "/usr/lib64/python2.7/pdb.py", line 1233, in _runscript
    self.run(statement)
  File "/usr/lib64/python2.7/bdb.py", line 400, in run
    exec cmd in globals, locals
  File "<string>", line 1, in <module>
  File "/home/danielkza/cobli/deploy/cloudformation/venv/bin/stacker", line 3, in <module>
    from stacker.logger import setup_logging
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/stacker/commands/stacker/build.py", line 58, in run
    dump=options.dump)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/stacker/actions/base.py", line 188, in execute
    self.pre_run(*args, **kwargs)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/stacker/actions/build.py", line 341, in pre_run
    outline
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/stacker/actions/build.py", line 148, in handle_hooks
    context=context
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/stacker/util.py", line 403, in handle_hooks
    result = method(context=context, provider=provider, **kwargs)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/stacker/hooks/aws_lambda.py", line 501, in upload_lambda_functions
    ensure_s3_bucket(s3_client, bucket_name, bucket_region)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/stacker/util.py", line 514, in ensure_s3_bucket
    s3_client.head_bucket(Bucket=bucket_name)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/botocore/client.py", line 314, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/botocore/client.py", line 586, in _make_api_call
    api_params, operation_model, context=request_context)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/botocore/client.py", line 619, in _convert_to_request_dict
    api_params, operation_model, context)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/botocore/client.py", line 648, in _emit_api_params
    params=api_params, model=operation_model, context=context)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/botocore/hooks.py", line 227, in emit
    return self._emit(event_name, kwargs)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/botocore/hooks.py", line 210, in _emit
    response = handler(**kwargs)
  File "/home/danielkza/cobli/deploy/cloudformation/venv/lib/python2.7/site-packages/botocore/handlers.py", line 217, in validate_bucket_name
    if VALID_BUCKET.search(bucket) is None:
TypeError: expected string or buffer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant