[英]Can I set the parameters in an AWS CloudFormation launch URL?
I need to point my users to a cloudformation stack that they will need to run, but I'd like to be able to personalize it based on the user. 我需要将用户指向他们需要运行的cloudformation堆栈,但我希望能够根据用户对其进行个性化设置。 I've read this and I would like to create a URL like: 我已经读过这篇文章了 ,我想创建一个像这样的URL:
https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/new?stackName=SomeName&MyParam=blah&templateURL=https://s3.amazonaws.com/mytemplate.json https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/new?stackName=SomeName&MyParam=blah&templateURL=https://s3.amazonaws.com/mytemplate.json
Notice the "MyParam=blah" in the middle. 请注意中间的“MyParam = blah”。 The user can still change the parameter to whatever they want, but I'd like to be able to set a default. 用户仍然可以将参数更改为他们想要的任何内容,但我希望能够设置默认值。 Any ideas, other than writing a custom Cloudformation template per user? 除了为每个用户编写自定义Cloudformation模板之外的任何想法?
[ Update ]: As of Jul 14 2017 , it is now possible to specify template parameters in URL query parameters provided to the launch stack URL. [ 更新 ]:自2017年7月14日起 ,现在可以在提供给启动堆栈URL的URL查询参数中指定模板参数。 Use the param_parameterName
format to specify template parameters, eg: 使用param_parameterName
格式指定模板参数,例如:
https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/review?stackName=SomeName¶m_MyParam=blah&templateURL=https://s3.amazonaws.com/mytemplate.json https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/review?stackName=SomeName¶m_MyParam=blah&templateURL=https://s3.amazonaws.com/mytemplate.json
See Creating Quick-Create Links for Stacks for full details. 有关完整详细信息,请参阅为堆栈创建快速创建链接 。
[Original answer, Feb 10 2017] : [原始答案,2017年2月10日] :
It is not possible to preset default parameters directly via an AWS CloudFormation launch URL. 无法通过AWS CloudFormation启动URL直接预设默认参数。 stackName
and templateURL
are the only two URI fragment components that are parsed by the JavaScript code executed on this page. stackName
和templateURL
是由此页面上执行的JavaScript代码解析的唯一两个URI片段组件。
Refer to the current CloudFormation Console JavaScript source to confirm this, specifically the parseRouteParams
function in the StackInfo
object used by the CreateStackController
: 请参阅当前的CloudFormation控制台JavaScript源以确认这一点,特别是CreateStackController
使用的StackInfo
对象中的parseRouteParams
函数:
this.parseRouteParams = function(a) {
a = _.reduce(a, function(a, b, d) {
a[d] = decodeURIComponent(b);
return a
}, a);
_.extend(this, _.pick(a, "stackName", "templateURL"))
}
Here are some other ideas: 以下是其他一些想法:
Default
value of a Property in your CloudFormation template based on a provided query parameter, uploads the rendered template to an S3 bucket, then redirects to the create-stack page providing the URL to the newly-rendered template. 编写一些服务器端代码,根据提供的查询参数在CloudFormation模板中动态呈现Property的Default
值,将呈现的模板上传到S3存储桶,然后重定向到create-stack页面,提供新的URL呈现的模板。 create-stack
, or build your own web interface to dynamically provide default parameters. 使用CreateStack API的另一个接口,例如AWS CLI create-stack
,或构建您自己的Web界面以动态提供默认参数。 You can use our new quick launch URL to supply parameters to the Cloudformation Console. 您可以使用我们的新快速启动URL为Cloudformation Console提供参数。 It supports Parameters using param_Foo syntax. 它使用param_Foo语法支持参数。
Here is an example for a sample APP 以下是示例APP的示例
https://eu-central-1.console.aws.amazon.com/cloudformation/home?region=eu-central-1#/stacks/create/review?templateURL=https://s3-eu-central-1.amazonaws.com/cloudformation-templates-eu-central-1/WordPress_Single_Instance.template&stackName=MyWPBlog¶m_DBName=mywpblog¶m_InstanceType=t2.medium¶m_KeyName=MyKeyPairUSEast1 https://eu-central-1.console.aws.amazon.com/cloudformation/home?region=eu-central-1#/stacks/create/review?templateURL=https://s3-eu-central-1 .amazonaws.com / cloudformation模板-EU-中央-1 / WordPress_Single_Instance.template&stackName = MyWPBlog&param_DBName = mywpblog&param_InstanceType = t2.medium&param_KeyName = MyKeyPairUSEast1
Please note that this does not support deep linking for No Echo parameters, by design. 请注意,根据设计,这不支持No Echo参数的深度链接。
More info: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-console-create-stacks-quick-create-links.html 更多信息: https : //docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-console-create-stacks-quick-create-links.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.