我正在尝试使用权杖!cmd 挂钩(在创建/更新之前)设置环境变量,然后可以通过 sceptre_user_data 和对其进行解析!同一配置文件中的environment_variable 解析器。
从shell执行该命令时效果很好,但是由于某些原因,!cmd挂钩在运行时无法执行赋值
不知道,如果我在这里丢失了任何东西
tfrecordWriter = tf.python_io.TFRecordWriter('a.tfrecords')
答案 0 :(得分:0)
不幸的是,目前您需要一个自定义解析器
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)
setup.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'