aws cloudformation update-stack --stack-name prod-hi-123456789 --parameters file://output/params/prod-hi-123456789.json --template-body file://output/prod-hi.json
349614
def update_stack(params)
      unless stack_exists?(@stack_name)
        puts "Cannot update a stack because the #{@stack_name} does not exists."
        return
      end
      exist_unless_updatable(stack_status(@stack_name))

      message = "Updating #{@stack_name} stack"
      error = nil
      if @options[:noop]
        message = "NOOP #{message}"
      else
        diff.run if @options[:diff]
        preview.run if @options[:preview]
        are_you_sure?(:update)

        if @options[:change_set] # defaults to this
          message << " via change set: #{preview.change_set_name}"
          change_set_update
        else
          standard_update(params)
        end
      end
      puts message unless @options[:mute] || error
    end
372919
function prepareStackTrace(error, stack) {
  if (emptyCacheBetweenOperations) {
    fileContentsCache = {};
    sourceMapCache = {};
  }

  var name = error.name || 'Error';
  var message = error.message || '';
  var errorString = name + ": " + message;

  return errorString + stack.map(function(frame) {
    return '\n    at ' + wrapCallSite(frame);
  }).join('');
}
418399
def load_cloudformation_template(path=None):
    
    if not path:
        path = os.path.abspath('cloudformation.py')
    else:
        path = os.path.abspath(path)
    if isinstance(path, six.string_types):
        try:
            sp = sys.path
            # temporarily add folder to allow relative path
            sys.path.append(os.path.abspath(os.path.dirname(path)))
            cloudformation = imp.load_source('cloudformation', path)
            sys.path = sp  # restore
            # use cfn template hooks
            if not check_hook_mechanism_is_intact(cloudformation):
                # no hooks - do nothing
                log.debug(
                    'No valid hook configuration: \'%s\'. Not using hooks!',
                    path)
            else:
                if check_register_present(cloudformation):
                    # register the template hooks so they listen to gcdt_signals
                    cloudformation.register()
            return cloudformation, True
        except GracefulExit:
            raise
        except ImportError as e:
            print('could not find package for import: %s' % e)
        except Exception as e:
            print('could not import cloudformation.py, maybe something wrong ',
                  'with your code?')
            print(e)
    return None, False
1816
def exit_unless_updateable!
      stack_name = Jets::Naming.parent_stack_name
      exists = stack_exists?(stack_name)
      return unless exists # continue because stack could be updating

      stack = cfn.describe_stacks(stack_name: stack_name).stacks.first
      status = stack["stack_status"]
      if status =~ /^ROLLBACK_/ ||
         status =~ /_IN_PROGRESS$/
        region = `aws configure get region`.strip rescue "us-east-1"
        url = "https://console.aws.amazon.com/cloudformation/home?region=#{region}#/stacks"
        puts "The parent stack of the #{Jets.config.project_name.color(:green)} project is not in an updateable state."
        puts "Stack name #{stack_name.color(:yellow)} status #{stack["stack_status"].color(:yellow)}"
        puts "Here's the CloudFormation url to check for more details #{url}"
        exit 1
      end
    end
781314
def _get_openstack_release(self):
        
        # Must be ordered by OpenStack release (not by Ubuntu release):
        for i, os_pair in enumerate(OPENSTACK_RELEASES_PAIRS):
            setattr(self, os_pair, i)

        releases = {
            ('trusty', None): self.trusty_icehouse,
            ('trusty', 'cloud:trusty-kilo'): self.trusty_kilo,
            ('trusty', 'cloud:trusty-liberty'): self.trusty_liberty,
            ('trusty', 'cloud:trusty-mitaka'): self.trusty_mitaka,
            ('xenial', None): self.xenial_mitaka,
            ('xenial', 'cloud:xenial-newton'): self.xenial_newton,
            ('xenial', 'cloud:xenial-ocata'): self.xenial_ocata,
            ('xenial', 'cloud:xenial-pike'): self.xenial_pike,
            ('xenial', 'cloud:xenial-queens'): self.xenial_queens,
            ('yakkety', None): self.yakkety_newton,
            ('zesty', None): self.zesty_ocata,
            ('artful', None): self.artful_pike,
            ('bionic', None): self.bionic_queens,
            ('bionic', 'cloud:bionic-rocky'): self.bionic_rocky,
            ('bionic', 'cloud:bionic-stein'): self.bionic_stein,
            ('cosmic', None): self.cosmic_rocky,
            ('disco', None): self.disco_stein,
        }
        return releases[(self.series, self.openstack)]
179942
def dump_prod id
      target_path = File.expand_path("../../fixtures/trunk-#{id}.dump", __FILE__)
      puts "Dumping production database from Heroku (works only if you have access to the database)"
      command = "curl -o #{target_path} \`heroku pg:backups public-url #{id} -a cocoapods-trunk-service\`"
      puts "Executing command:"
      puts command
      result = system command
      if result
        puts "Production database snapshot #{id} dumped into #{target_path}"
      else
        raise "Could not dump #{id} from production database."
      end
    end
620336
def update_release(id, **kwargs):
    
    data = update_release_raw(id, **kwargs)
    if data:
        return utils.format_json(data)
1199185
def _set_update(self):
        
        try:
            self._updateStack = False
            stack_name = self._config.get('environment', {}).get('stack_name', None)
            response = self._cloudFormation.describe_stacks(StackName=stack_name)
            stack = response['Stacks'][0]
            if stack['StackStatus'] == 'ROLLBACK_COMPLETE':
                logging.info('stack is in ROLLBACK_COMPLETE status and should be deleted')
                del_stack_resp = self._cloudFormation.delete_stack(StackName=stack_name)
                logging.info('delete started for stack: {}'.format(stack_name))
                logging.debug('delete_stack returned: {}'.format(json.dumps(del_stack_resp, indent=4)))
                stack_delete = self.poll_stack()
                if not stack_delete:
                    return False

            if stack['StackStatus'] in ['CREATE_COMPLETE', 'UPDATE_COMPLETE', 'UPDATE_ROLLBACK_COMPLETE']:
                self._updateStack = True
        except:
            self._updateStack = False

        logging.info('update_stack: ' + str(self._updateStack))
        return True
436005
def stack_outputs(self, name):
        
        try:
            stack = self.cf_client.describe_stacks(StackName=name)['Stacks'][0]
            return {x['OutputKey']: x['OutputValue'] for x in stack['Outputs']}
        except botocore.client.ClientError:
            return {}
763964
function deployS3(config) {
  if (!config.credentials.accessKeyId || !config.credentials.secretAccessKey) {
    gutil.log(
      gutil.colors.red('AWS S3 credentials missing, skipping upload...'),
    );
    return;
  }

  // create a new publisher
  const publisher = aws.create(config.credentials);

  // define custom headers
  const headers = {
    'Cache-Control': 'max-age=315360000, no-transform, public',
  };
  return (
    gulp
      .src(config.assetsPath)
      .pipe(
        rename(function(filepath) {
          filepath.dirname = path.join(config.dirname, filepath.dirname);
        }),
      )
      // gzip, Set Content-Encoding headers and add .gz extension
      .pipe(gulpIf(file => !file.path.match(/\.(mp4|ogg|webm|avi|mov|mkv)$/), aws.gzip()))
      // publisher will add Content-Length, Content-Type and headers specified above
      // If not specified it will set x-amz-acl to public-read by default
      .pipe(publisher.publish(headers))
      // create a cache file to speed up consecutive uploads
      .pipe(publisher.cache())
      // print upload updates to console
      .pipe(aws.reporter())
  );
}
13331
def describe_change_set(awsclient, change_set_name, stack_name):
    
    client = awsclient.get_client('cloudformation')

    status = None
    while status not in ['CREATE_COMPLETE', 'FAILED']:
        response = client.describe_change_set(
            ChangeSetName=change_set_name,
            StackName=stack_name)
        status = response['Status']
        # print('##### %s' % status)
        if status == 'FAILED':
            print(response['StatusReason'])
        elif status == 'CREATE_COMPLETE':
            for change in response['Changes']:
                print(json2table(change['ResourceChange']))
446075
def create_stack(self, name):
        
        deployment = find_exact(self.api.deployments, name=name)
        if not deployment:
            try:
                # TODO: replace when python-rightscale handles non-json
                self.api.client.post(
                        '/api/deployments',
                        data={'deployment[name]': name},
                        )
            except HTTPError as e:
                log.error(
                        'Failed to create stack %s. '
                        'RightScale returned %d:\n%s'
                        % (name, e.response.status_code, e.response.content)
                        )
1148197
async function ensureAwsCfStack(cli, params) {
  if (await awsCfStackExists(cli, params.StackName)) {
    await updateAwsCfStack(cli, params);
  } else {
    await createAwsCfStack(cli, params);
  }
  const output = await awsDescribeCfStack(cli, params.StackName);
  return output;
}
873839
def update(self, ng_template_id, name=NotUpdated, plugin_name=NotUpdated,
               plugin_version=NotUpdated, flavor_id=NotUpdated,
               description=NotUpdated, volumes_per_node=NotUpdated,
               volumes_size=NotUpdated, node_processes=NotUpdated,
               node_configs=NotUpdated, floating_ip_pool=NotUpdated,
               security_groups=NotUpdated, auto_security_group=NotUpdated,
               availability_zone=NotUpdated,
               volumes_availability_zone=NotUpdated, volume_type=NotUpdated,
               image_id=NotUpdated, is_proxy_gateway=NotUpdated,
               volume_local_to_instance=NotUpdated, use_autoconfig=NotUpdated,
               shares=NotUpdated, is_public=NotUpdated,
               is_protected=NotUpdated, volume_mount_prefix=NotUpdated,
               boot_from_volume=NotUpdated,
               boot_volume_type=NotUpdated,
               boot_volume_availability_zone=NotUpdated,
               boot_volume_local_to_instance=NotUpdated):
        """"""

        data = {}
        self._copy_if_updated(
            data, name=name, plugin_name=plugin_name,
            plugin_version=plugin_version, flavor_id=flavor_id,
            description=description, volumes_per_node=volumes_per_node,
            volumes_size=volumes_size, node_processes=node_processes,
            node_configs=node_configs, floating_ip_pool=floating_ip_pool,
            security_groups=security_groups,
            auto_security_group=auto_security_group,
            availability_zone=availability_zone,
            volumes_availability_zone=volumes_availability_zone,
            volume_type=volume_type, image_id=image_id,
            is_proxy_gateway=is_proxy_gateway,
            volume_local_to_instance=volume_local_to_instance,
            use_autoconfig=use_autoconfig, shares=shares,
            is_public=is_public, is_protected=is_protected,
            volume_mount_prefix=volume_mount_prefix,
            boot_from_volume=boot_from_volume,
            boot_volume_type=boot_volume_type,
            boot_volume_availability_zone=boot_volume_availability_zone,
            boot_volume_local_to_instance=boot_volume_local_to_instance
        )

        return self._patch('/node-group-templates/%s' % ng_template_id, data,
                           'node_group_template')
813561
function readApi(file, fn) {
  var ext = path.extname(file);
  if ('.js' === ext || '.ts' === ext) {
    readJsDoc(file, fn);
  } else if ('.yml' === ext) {
    readYml(file, fn);
  } else if ('.coffee' === ext) {
    readCoffee(file, fn);
  } else {
    throw new Error('Unsupported extension \'' + ext + '\'');
  }
}
528698
async function getTemplateFile(templateDir, stackName) {
  const f = await Promise.any(
    _.map(['.yml', '.yaml', '.json', ''], async(ext) =>
      await utils.fileExists(`${path.join(templateDir, stackName)}${ext}`)));
  if (f) {
    return f;
  }
  throw new Error(`Stack template "${stackName}" not found!`);
}
183712
def s3_stack_push(self, blueprint, force=False):
        
        key_name = stack_template_key_name(blueprint)
        template_url = self.stack_template_url(blueprint)
        try:
            template_exists = self.s3_conn.head_object(
                Bucket=self.bucket_name, Key=key_name) is not None
        except botocore.exceptions.ClientError as e:
            if e.response['Error']['Code'] == '404':
                template_exists = False
            else:
                raise

        if template_exists and not force:
            logger.debug("Cloudformation template %s already exists.",
                         template_url)
            return template_url
        self.s3_conn.put_object(Bucket=self.bucket_name,
                                Key=key_name,
                                Body=blueprint.rendered,
                                ServerSideEncryption='AES256',
                                ACL='bucket-owner-full-control')
        logger.debug("Blueprint %s pushed to %s.", blueprint.name,
                     template_url)
        return template_url