Skip to content

Commit

Permalink
Cdk support package and deploy fix (#2996)
Browse files Browse the repository at this point in the history
* Fix --resolve-s3 --s3-bucket validation under guided flow

* Fix package resource assets
  • Loading branch information
hawflau committed Jun 29, 2021
1 parent 880b3ef commit 2cef205
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions samcli/commands/package/validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ def wrapped(*args, **kwargs):
# NOTE(sriram-mv): Both params and default_map need to be checked, as the option can be either be
# passed in directly or through configuration file.
# If passed in through configuration file, default_map is loaded with those values.
guided = ctx.params.get("guided", False) or ctx.params.get("g", False)
resolve_s3_provided = ctx.params.get("resolve_s3", False) or ctx.default_map.get("resolve_s3", False)
s3_bucket_provided = ctx.params.get("s3_bucket", False) or ctx.default_map.get("s3_bucket", False)
either_required = stack.has_assets_of_package_type(ZIP) if stack is not None else False
if s3_bucket_provided and resolve_s3_provided:
if not guided and s3_bucket_provided and resolve_s3_provided:
raise PackageResolveS3AndS3SetError()
if either_required and not s3_bucket_provided and not resolve_s3_provided:
if not guided and either_required and not s3_bucket_provided and not resolve_s3_provided:
raise PackageResolveS3AndS3NotSetError()

return func(*args, **kwargs)
Expand Down
6 changes: 6 additions & 0 deletions samcli/lib/iac/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,12 @@ def find_function_resources_of_package_type(self, package_type: str) -> List[Res
_function_resources.append(resource)
return _function_resources

def get_overrideable_parameters(self):
"""
Return a dict of parameters that are override-able, i.e. not added by iac
"""
return {key: val for key, val in self.get("Parameters", {}).items() if not val.added_by_iac}

def as_dict(self):
"""
return the stack as a dict for JSON serialization
Expand Down
4 changes: 3 additions & 1 deletion samcli/lib/package/packageable_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ def export(self, resource, parent_dir):
if not resource.is_packageable():
return

# we can safely assume resource.assets contains at lease one asset
if not resource.assets:
return
# resource.assets contains at lease one asset
asset = resource.assets[0]

if not asset.source_path and not self.PACKAGE_NULL_PROPERTY:
Expand Down

0 comments on commit 2cef205

Please sign in to comment.