Похоже, что это ошибка в реализации CloudFormation.
Если вы измените ClientID с us-east-1-1_string
на us_east_1_1_string
, шаблон будет создан, и пользовательский интерфейс покажет правильную исходную строку (с черточками).
Поскольку CloudFormation также не имеет функции замены, единственный способ заменить строку - это разделение и повторное соединение частей строки.
Таким образом, для 3 тире вам понадобится следующая конструкция:
"ClientId": {
"Fn::Join": ["_",
[{"Fn::Select": ["0",{"Fn::Split": ["-",{ "Ref": "UserPool"}]}]},
{"Fn::Select": ["1",{"Fn::Split": ["-",{ "Ref": "UserPool"}]}]},
{"Fn::Select": ["2",{"Fn::Split": ["-",{ "Ref": "UserPool"}]}]},
{"Fn::Select": ["3",{"Fn::Split": ["-",{ "Ref": "UserPool"}]}]}
]
]
}
Я пытался выполнить ваш шаблон, и он всегда генерировал для меня строку с двумя штрихами. Так что для версии с двумя тире это будет полный шаблон:
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
"CognitoUserPoolName": {
"Description": "Name of the Cognito user pool as a parameter passed into this template.",
"Type": "String"
}
},
"Resources": {
"UserPool": {
"Type": "AWS::Cognito::UserPool",
"Properties": {
"UserPoolName": {
"Ref": "CognitoUserPoolName"
},
"Policies": {
"PasswordPolicy": {
"MinimumLength": 8,
"RequireUppercase": true,
"RequireLowercase": true,
"RequireNumbers": true,
"RequireSymbols": true
}
},
"Schema": [{
"Name": "name",
"AttributeDataType": "String",
"Mutable": true,
"Required": false
},
{
"Name": "email",
"AttributeDataType": "String",
"Mutable": false,
"Required": true
},
{
"Name": "phone_number",
"AttributeDataType": "String",
"Mutable": false,
"Required": false
}
],
"LambdaConfig": {},
"AutoVerifiedAttributes": [
"email"
],
"UsernameAttributes": [
"email"
],
"SmsVerificationMessage": "Your verification code is {####}. ",
"EmailVerificationMessage": "Your app verification code is {####}. ",
"EmailVerificationSubject": "Your app verification code",
"SmsAuthenticationMessage": "Your authentication code is {####}. ",
"MfaConfiguration": "OFF",
"EmailConfiguration": {},
"UserPoolTags": {},
"AdminCreateUserConfig": {
"AllowAdminCreateUserOnly": false,
"UnusedAccountValidityDays": 7,
"InviteMessageTemplate": {
"SMSMessage": "Your username is {username} and temporary password is {####}. ",
"EmailMessage": "Your username is {username} and temporary password is {####}. ",
"EmailSubject": "Your temporary password"
}
}
}
},
"UserPoolClient": {
"Type": "AWS::Cognito::UserPoolClient",
"Description": "App Client.",
"DependsOn": "UserPool",
"Properties": {
"ClientName": {
"Fn::Sub": "${CognitoUserPoolName}Client"
},
"ExplicitAuthFlows": [
"ADMIN_NO_SRP_AUTH"
],
"GenerateSecret": false,
"RefreshTokenValidity": 30,
"UserPoolId": {
"Ref": "UserPool"
}
}
},
"IdentityPool": {
"Type": "AWS::Cognito::IdentityPool",
"DependsOn": ["UserPool", "UserPoolClient"],
"Properties": {
"AllowUnauthenticatedIdentities": false,
"CognitoIdentityProviders": [{
"ClientId": {
"Fn::Join": [
"_",
[
{
"Fn::Select": [
"0",
{
"Fn::Split": [
"-",
{
"Ref": "UserPool"
}
]
}
]
},
{
"Fn::Select": [
"1",
{
"Fn::Split": [
"-",
{
"Ref": "UserPool"
}
]
}
]
},
{
"Fn::Select": [
"2",
{
"Fn::Split": [
"-",
{
"Ref": "UserPool"
}
]
}
]
}
]
]
},
"ProviderName": {
"Fn::GetAtt": [
"UserPool",
"ProviderName"
]
}
}],
"IdentityPoolName": {
"Fn::Sub": "${CognitoUserPoolName}IdentityPool"
}
}
}
},
"Outputs": {
"UserPoolARN": {
"Value": {
"Fn::GetAtt": [
"UserPool",
"Arn"
]
}
}
}
}