Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions samtranslator/model/apigateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class ApiGatewayAccount(Resource):


class ApiGatewayDeployment(Resource):
_X_HASH_DELIMITER = "||"

resource_type = 'AWS::ApiGateway::Deployment'
property_types = {
'Description': PropertyType(False, is_str()),
Expand Down Expand Up @@ -90,13 +92,15 @@ def make_auto_deployable(self, stage, openapi_version=None, swagger=None):
# to prevent redeployment when API has not changed

# NOTE: `str(swagger)` is for backwards compatibility. Changing it to a JSON or something will break compat
hash_input = str(swagger)
hash_input = [str(swagger)]
if openapi_version:
hash_input = hash_input + str(openapi_version)
generator = logical_id_generator.LogicalIdGenerator(self.logical_id, hash_input)
hash_input.append(str(openapi_version))

data = self._X_HASH_DELIMITER.join(hash_input)
generator = logical_id_generator.LogicalIdGenerator(self.logical_id, data)
self.logical_id = generator.gen()
hash = generator.get_hash(length=40) # Get the full hash
self.Description = "RestApi deployment id: {}".format(hash)
digest = generator.get_hash(length=40) # Get the full hash
self.Description = "RestApi deployment id: {}".format(digest)
stage.update_deployment_ref(self.logical_id)


Expand Down