def validate(args):
"""validate local stack(s)"""
stacks = args.stack
# validate all stacks
if args.all:
stacks = local_stacks()
# filter for existing stacks
elif stacks:
stacks = [stack for stack in stacks if stack in local_stacks()]
# bail if no stack to validate
if not stacks:
LOG.warning(
'this command needs a list of local stacks, or the --all flag to validate all stacks')
sys.exit(1)
# action
cfn = get_cfn()
retval = 0
for stack in stacks:
tpl_body = load_template(stack, True)
try:
cfn.validate_template(TemplateBody=tpl_body)
res = 'ok'
except botocore.exceptions.ClientError as err:
res = 'not ok: %s' % str(err)
retval = 1
print('%s:%s %s' % (stack, ''.rjust(max([len(s) for s in stacks]) - len(stack)), res))
sys.exit(retval)
评论列表
文章目录