Catalog item name

I have created a catalog item using cloudformation blueprint, but now having issue with name since hardcoding the name does not allow more than 1 instance. How to make the name variable?

Dynamically Pass Morpheus Variables to Cloudformation

So obviously with the power of Morpheus in front of your Cloudformation code (applicable to ARM and Terraform as well) admin’s have the ability to RBAC control it. But another cool thing is passing Morpheus variables into your code and being able to pull required inputs from manual/static lists, REST endpoints, and free form entries.

Here I’ve created a simple S3 bucket deploy with CF (a little redundant as S3 management is a native feature in Morpheus). Now I could’ve used ‘params’ and Morpheus would parse those inputs for users via the UI/CLI/API. However, I have replaced ‘params’ with ‘mappings’, and now I can programmatically pass values that are Morpheus native or user inputted into my code.

So what does that mean? NO MORE hard coding allowed values inside of your CF. Instead use Option Types and Option Lists that can be generated dynamically.

Variable Passing with Cloudformation and Morpheus

  1. Create Cloudformation code. Instead of utilizing params in the Cloudformation, utilize mapping logic. Note: Params can still be utilized (or a mix of the two), but you will lose the tight integration with Morpheus, passing variables into scripts easily, and pulling dynamic listing values.

a. Here’s a block of example code to create a S3 Bucket.

{
"Mappings" : {
"MorpheusMap" : {
"instance"  : {"Name" : "<%=instance.name%>"},
"application"   : {"Name" : "<%=customOptions.application%>"}
       }
   },
"Resources" : {
"S3Bucket" : {
"Type" : "AWS::S3::Bucket",
"DeletionPolicy": "Retain",
"Properties" : {
"BucketName" : {"Fn::FindInMap" : ["MorpheusMap", "instance", "Name"]},
"Tags" : [
                   {"Key" : "Application" , "Value" : {"Fn::FindInMap" : ["MorpheusMap", "application", "Name"]}}
               ]
           }
       }
   }
}
  1. The Cloudformation will be either placed in a repo, or directly inputted under ‘Provisioning > Library > Spec Templates’

Adding my CF Spec Template Locally. This can easily reference a GIT repo as well!

  1. Now create your Instance Type and attach any of the Option Types that will be consumed by this script. In my example, I have a text box with fieldname ‘Application’ that I want to prompt for.

Here’s the Option Type I’m going to prompt my users.

The Instance Type for my S3 deploy with the Custom Option Type.

  1. Provision your Instance Type and win!

My Instance Wizard with Application Name prompt. This could easily be boolean values, drop downs, encrypted passwords, etc.

My S3 Instance

What AWS Sees

My tag!

That’s a capy/paste of a post pre-morpheus forums. So it may be slightly old references but you could utilize inputs and cloudformation spec templates. Using a CF map you can inject variables from Morpheus.

Thanks, but this is not what I asked for. There is a name variable for Morpheus Catalog, we need to use this variable so that we can have multiple instances. What I am using like below but I do not want user to provide me name to avoid conflict.

name: ‘<%=customOptions.lbName%>’

rather would like to use something like

“${groupCode}${sequence+10000}”

But the later is not working

The syntax would be same as you do for customOptions. It worked for me

image

@aabraham Thanks. I am talking About Morpheus instance name, not alb name. By the way, based on your advise I have put the name like below -

name: ‘AWSALB<%=customOptions.grouplist%><%=sequence+100%>’

It created a Morpheus Instance (Provisioning → Catalog → Inventory) as AWSALB18101 and corresponding cloudformation stack.

But next time I wanted to launch another instance, it complains as the following in the catalog order.
Name: must be unique

Hi @Ripon_Banik that should be a naming policy Scope to a Group. This would ensure unique names for instances.

We need unique name, don’t we? Otherwise will be conflict both in Morpheus and AWS. But the issue here sequence variable is not interpolating, we need it to be working for cft based blueprint/catalog. currently it is working only for instance.