in src/servicecatalog.py [0:0]
def uploadArtifact(self):
""" Uploads the product (CloudFormation template) to artifact buckets
:return:
"""
if (os.environ['BuildType'] == 'deploy'):
response = self.s3_resource.meta.client.upload_file('cloudformation.json', self.bucketName,
"servicecatalog/%s/%s/cloudformation.json" % (
self.applicationName, self.version))
templateUrl = "https://%s.s3.amazonaws.com/servicecatalog/%s/%s/cloudformation.json" % (
self.bucketName, self.applicationName, self.version)
return templateUrl
else:
self.data['Parameters']['appName']['Default'] = self.applicationName
self.data['Parameters']['Version']['Default'] = self.version
print(self.data)
with open('cloudformation.json', 'w') as outfile:
json.dump(self.data, outfile)
response = self.s3_resource.meta.client.upload_file('cloudformation.json', self.bucketName,
"servicecatalog/%s/%s/cloudformation.json" % (
self.applicationName, self.version))
templateUrl = "https://%s.s3.amazonaws.com/servicecatalog/%s/%s/cloudformation.json" % (
self.bucketName, self.applicationName, self.version)
with ZipFile('package.zip', 'w') as myzip:
myzip.write('cloudformation.json')
myzip.write('servicecatalog.py')
myzip.write('version.json')
myzip.write('buildspec.yml')
response = self.s3_resource.meta.client.upload_file('package.zip', self.bucketName,
"servicecatalog/%s/%s/package.zip" % (
self.applicationName, self.version))
return templateUrl