简体   繁体   English

AWS Cloudformation添加确认密码参数

[英]AWS Cloudformation Add Confirm Password parameter

I am creating a cloudformation template on AWS and have successfully added the username and password parameter which is required as a user input. 我正在AWS上创建cloudformation模板,并成功添加了用户输入所需的username和password参数。 But is there any way to add "Confirm password" field as well ? 但是还有什么方法可以添加“确认密码”字段?

It finally worked after I specified 3 parameters - username, password, confirm password and then added the following rule section in the template: 我指定了3个参数-用户名,密码,确认密码,然后在模板中添加了以下规则部分,终于可以使用了:

JSON: JSON:

"Rules" : {
    "matchPasswords" : {
        "Assertions" : [
        {
            "Assert" : {"Fn::Equals":[{"Ref":"Password"},{"Ref":"ConfirmPassword"}]},
            "AssertDescription" : "Passwords do not match"
        }
        ]
    }}

YAML: YAML:

Rules:
  'matchPasswords':
    Assertions:
      - Assert:
          Fn::Equals:
            - Ref: 'Password'
            - Ref: 'ConfirmPassword'
        AssertDescription: 'Passwords do not match'

You could accept 3 parameters - username, password, confirm password. 您可以接受3个参数-用户名,密码,确认密码。 Specify a condition like "password-match" and then, add this condition to all your resources. 指定一个条件,例如“ password-match”,然后将此条件添加到所有资源中。 So if the passwords don't match, nothing will be created. 因此,如果密码不匹配,则不会创建任何内容。

Check this page to understand the use of conditions better https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html 检查此页面以更好地了解条件的使用https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM