pythonaws-cloudformationtroposphere

How to fix expected <type 'basestring'> in python code


I am using Troposphere to create CloudFormation templates.

If I use a variable or string I get the error - <class 'troposphere.efs.FileSystem'>, expected <type 'basestring'>

I am new to troposphere and python so any help is appreciated.

My code when using strings

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

My code when using variables

MyEFSMountTarget1a = t.add_resource(MountTarget(
    "MyEFSMountTarget1a",
    FileSystemId=(efs_file_system),
    SecurityGroups=[efs_security_group],
    SubnetId=PublicSubnet1a
))

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

What I am doing is importing values from another cloudformation stack and using them in another stack.

Here is how I populate the variables -

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

They are populated correctly and I assumed they were jutt strings - which they are. So I guess I can not use strings for SecurityGroups or SubnetId? Do I need to convert the strings to a basestring and how?

Ernie


Solution

  • My mistake - It was the filesystem id - I forgot to add a ref to it FileSystemId=Ref(efs_file_system),