不幸的是,您目前需要一个自定义解析器
sceptre_plugins_cmd_extras.py
import os
import subprocess
from sceptre.resolvers import Resolver
class CmdResolver(Resolver):
"""
Resolver for running shell commands and returning the value
:param argument: Name of the environment variable to return.
:type argument: str
"""
def resolve(self):
"""
Runs a command and returns the output as a string
:returns: Value of the environment variable.
:rtype: str
"""
return subprocess.check_output(self.argument, shell=True)
安装程序.py
from setuptools import setup
setup(
name='sceptre-plugins-cmd-extras',
description="Extra Sceptre Plguins (Hook & Resolver) for subprocess",
keywords="sceptre,cloudformation",
version='0.0.1',
author="Cloudreach",
author_email="juan.canham@cloudreach.com",
license='Apache2',
url="https://github.com/cloudreach/sceptre",
entry_points={
'sceptre.resolvers': [
'cmd = sceptre_plugins_cmd_extras:CmdResolver',
],
},
py_modules=['sceptre_plugins_cmd_extras'],
install_requires=["sceptre"],
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators"
"Natural Language :: English",
"Environment :: Plugins",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7"
]
)
但是你需要使你的命令幂等(类似)
sceptre_user_data:
ObjectVersion: !cmd aws s3api get-object --bucket bucket-name --key path --query 'VersionId' || aws s3api put-object --body file --bucket bucket-name --key path --query 'VersionId'