如何修复python cod中的预期<type'basestring'>

2024-05-04 06:57:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用对流层来创建云形成模板。在

如果我使用变量或字符串,我会得到错误-<class 'troposphere.efs.FileSystem'>, expected <type 'basestring'>

我是对流层和Python的新手,所以任何帮助都是感激的。在

使用字符串时的我的代码

MyEFSMountTarget1a = t.add_resource(MountTarget(
    "MyEFSMountTarget1a",
    FileSystemId=(efs_file_system),
    SecurityGroups=["sg-0c69656095ee1a5b8"],
    SubnetId="subnet-091b67136896b2be8"
))

使用变量时的我的代码

^{pr2}$

错误:<class 'troposphere.efs.MountTarget'>: MyEFSMountTarget1a.FileSystemId is <class 'troposphere.efs.FileSystem'>, expected <type 'basestring'>

我要做的是从另一个cloudformation堆栈导入值并在另一个堆栈中使用它们。在

下面是我如何填充变量-

efs_security_group = ImportValue(Join("-", [params.ENVIRONMENT, "efsSecurityGroup"]),)
PublicSubnet1a = ImportValue(Join("-", [params.ENVIRONMENT, "PublicSubnet1a"]),)

它们被正确地填充了,我假设它们是jutt字符串-它们是。所以我想我不能将字符串用于SecurityGroups或SubnetId?我需要将字符串转换为basestring吗?如何转换?在

厄尼


Tags: 字符串代码type错误classexpectedtropospherefilesystem