æ°ããã«ã¹ã¿ã å±æ§ãè¿œå ããŠããcognitoãŠãŒã¶ãŒããŒã«ã®åäœæã匷å¶ãããããšã¯ãããŸããã
$ terraform -v
Terraform v0.11.4
+ provider.aws v1.11.0
aws_cognito_user_pool
variable "region" {
default = "us-east-1"
}
provider "aws" {
region = "${var.region}"
}
resource "aws_cognito_user_pool" "pool" {
name = "bug-test-pool"
/*
schema {
attribute_data_type = "Number"
developer_only_attribute = false
mutable = false
name = "custom-attribute"
required = false
}
*/
}
äžèšã®ã«ã¹ã¿ã å±æ§ãè¿œå ããåŸã®å®è¡äžã®terraform plan
åºåã
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
aws_cognito_user_pool.pool: Refreshing state... (ID: us-east-1_Cj77gRCdj)
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement
Terraform will perform the following actions:
-/+ aws_cognito_user_pool.pool (new resource required)
id: "us-east-1_Cj77gRCdj" => <computed> (forces new resource)
admin_create_user_config.#: "1" => <computed>
arn: "arn:aws:cognito-idp:us-east-1:326947223243:userpool/us-east-1_Cj77gRCdj" => <computed>
creation_date: "2018-03-22T19:06:44Z" => <computed>
email_verification_message: "" => <computed>
email_verification_subject: "" => <computed>
lambda_config.#: "0" => <computed>
last_modified_date: "2018-03-22T19:06:44Z" => <computed>
mfa_configuration: "OFF" => "OFF"
name: "bug-test-pool" => "bug-test-pool"
password_policy.#: "1" => <computed>
schema.#: "" => "1" (forces new resource)
schema.2616754751.attribute_data_type: "" => "Number"
schema.2616754751.developer_only_attribute: "" => "false"
schema.2616754751.mutable: "" => "false"
schema.2616754751.name: "" => "custom-attribute"
schema.2616754751.number_attribute_constraints.#: "" => "0"
schema.2616754751.required: "" => "false"
schema.2616754751.string_attribute_constraints.#: "" => "0"
verification_message_template.#: "1" => <computed>
Plan: 1 to add, 0 to change, 1 to destroy.
------------------------------------------------------------------------
Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.
ãªã
cognitoãŠãŒã¶ãŒããŒã«ãç Žæ£ããã³åæ§ç¯ããã«å±æ§ãè¿œå ããŸãã ããã¯ãcognito UIããã³APIïŒhttps://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AddCustomAttributes.htmlïŒãéããŠãµããŒããããŠããŸãã
cognitoãŠãŒã¶ãŒããŒã«ãåæ§ç¯ãããŸããã
schema.#: "" => "1" (forces new resource)
terraform apply
-æ°ãããŠãŒã¶ãŒããŒã«ãäœæããŸãterrform plan
-åºåã衚瀺ãããšãcognitoãŠãŒã¶ãŒããŒã«ãåæ§ç¯ãããããšãããããŸãããªã
ãªã
AWSã¯ã«ã¹ã¿ã å±æ§ã®åé€ãã«ã¹ã¿ã å±æ§ã®æŽæ°ããµããŒãããŠããªãããã§ãããããã«ã¹ã¿ã å±æ§ã®åé€ãã©ã®ããã«æ©èœãããããããŸããã
çãããããã«ãuser_poolã®äžéšãšããŠäœæãããã«ã¹ã¿ã å±æ§ãæŽæ°ãŸãã¯åé€ããããšã¯ã§ããŸããã ãããã£ãŠãçŸåšã®åäœãå¯äžã®æ¹æ³ã ãšæããŸãð€AWSããã¥ã¡ã³ãã®è©³çŽ°
ããã§ããå±æ§ãè¿œå ããããšãããããåé€ããããšã¯ã§ããŸããã ãã ããæ°ããå±æ§ãè¿œå ããããšã¯ã§ããŸãã
ãŠãŒã¶ãŒããŒã«å šäœãåäœæããã«ããã©ãã©ãŒã ãä»ããŠæ°ããå±æ§ãè¿œå ããããã®åé¿çã¯ãããŸããïŒ å°æ¥ãã¢ããªã±ãŒã·ã§ã³ã皌åããŠãããšãã«æ°ããå±æ§ãè¿œå ããã®ã¯é£ããããã§ãã
ç·šéïŒããŒãžã§ã³ã1.12ã«ãã°ããããã«èŠããŸãããããã¯ä¿®æ£ãããŸããã
ãããŸã§ã®éãTerraformã®å€éšïŒWebã³ã³ãœãŒã«ãCLIãªã©ïŒã§ãããå®è¡ããåŸã§Terraformæ§æãåæããããšãã§ããŸãã
ããå°ãç 究ãããŠããŸãã åé¡ãèŠã€ããŸããã ã¹ããŒãå±æ§ïŒç§ã®å Žåã¯StringïŒã«string_attribute_constraints
å«ãŸããŠããªãå Žåãæ¯åæ°ãããªãœãŒã¹ã匷å¶ãããŸãã
以äžã¯ãæ¯åæ°ãããªãœãŒã¹ãçæããŸãã
schema {
attribute_data_type = "String"
developer_only_attribute = false
mutable = false
name = "picture"
required = true
}
ããã¯ããŸãããïŒ
schema {
attribute_data_type = "String"
developer_only_attribute = false
mutable = false
name = "picture"
required = true
string_attribute_constraints {
min_length = 6
max_length = 32
}
}
ããããããã¯å¥ã®ãã°ã§ãã
@leonfsããã«customizediffé¢æ°ãå¿ èŠã ãšæããŸãã ããã¯ãããŒã«ãåäœæããå¿ èŠãããå Žåãšå€æŽããå¿ èŠãããå Žåã®thwbrulesãè©äŸ¡ããŸãã @bfladäœãããå¿ èŠãããã確èªããŠããã ããã°ãããã
@ Puneeth-nã¯ã-ãããªãããã§ãã çŸæç¹ã§ã¯ãã¹ããŒãã»ããã«ForceNew: true
ããããŸãããã«ã¹ã¿ã å±æ§ã®å Žåã¯æããã«ããã§ã¯ãããŸããã
IDãããã€ããŒïŒGoogleïŒããŠãŒã¶ãŒããŒã«ã«è¿œå ããåŸã«çºçããå¥ã®åé¡ãåç §ããŸããïŒäžèšãåç §ïŒã
AWSã¯ããããã€ããŒãè¿œå ããåŸã identities
ãšããã«ã¹ã¿ã å±æ§ãè¿œå ããã¹ããŒãã®ã»ãããå€æŽããŠããŸã£ããæ°ããããŒã«ã匷å¶çã«åäœæããããã§ãã ç§ãããã«çæçãªè§£æ±ºçãæäŸããããšãããããŸãããIDãããã€ããŒã䜿çšããããšãäºåã«ç¥ã£ãŠããå ŽåïŒãªãœãŒã¹ã®äœæïŒã«ã®ã¿æ©èœããŸãã
.tfãã¡ã€ã«ã«äœãå€æŽãããŠããªãå Žåã§ããterraformã¯ãŠãŒã¶ãŒããŒã«ã®ç Žæ£ãšäœæã匷å¶ããããã«èŠããŸãã
$ cat main.tf
provider "aws" {
}
resource "aws_cognito_user_pool" "pankajk_security" {
name = "pankajk-security"
email_verification_subject = "Your Verification Code"
email_verification_message = "Please use the following code: {####}"
alias_attributes = ["email", "preferred_username"]
auto_verified_attributes = ["email"]
verification_message_template {
default_email_option = "CONFIRM_WITH_CODE"
}
password_policy {
minimum_length = 10
require_lowercase = true
require_numbers = true
require_symbols = true
require_uppercase = true
}
schema {
attribute_data_type = "String"
developer_only_attribute = false
mutable = true
name = "email"
required = true
string_attribute_constraints {
min_length = 7
max_length = 256
}
}
schema {
attribute_data_type = "String"
developer_only_attribute = false
mutable = true
name = "oid"
required = false
number_attribute_constraints {
min_value = 1
max_value = 256
}
}
}
$ terraform -v
Terraform v0.11.7
+ provider.aws v1.14.1
$ãã©ãã©ãŒã ãé©çšãããŸã
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
+ aws_cognito_user_pool.pankajk_security
id: <computed>
admin_create_user_config.#: <computed>
alias_attributes.#: "2"
alias_attributes.1888159429: "preferred_username"
alias_attributes.881205744: "email"
arn: <computed>
auto_verified_attributes.#: "1"
auto_verified_attributes.881205744: "email"
creation_date: <computed>
email_verification_message: "Please use the following code: {####}"
email_verification_subject: "Your Verification Code"
lambda_config.#: <computed>
last_modified_date: <computed>
mfa_configuration: "OFF"
name: "pankajk-security"
password_policy.#: "1"
password_policy.0.minimum_length: "10"
password_policy.0.require_lowercase: "true"
password_policy.0.require_numbers: "true"
password_policy.0.require_symbols: "true"
password_policy.0.require_uppercase: "true"
schema.#: "2"
schema.1734507539.attribute_data_type: "String"
schema.1734507539.developer_only_attribute: "false"
schema.1734507539.mutable: "true"
schema.1734507539.name: "email"
schema.1734507539.number_attribute_constraints.#: "0"
schema.1734507539.required: "true"
schema.1734507539.string_attribute_constraints.#: "1"
schema.1734507539.string_attribute_constraints.0.max_length: "256"
schema.1734507539.string_attribute_constraints.0.min_length: "7"
schema.3768180960.attribute_data_type: "String"
schema.3768180960.developer_only_attribute: "false"
schema.3768180960.mutable: "true"
schema.3768180960.name: "oid"
schema.3768180960.number_attribute_constraints.#: "1"
schema.3768180960.number_attribute_constraints.0.max_value: "256"
schema.3768180960.number_attribute_constraints.0.min_value: "1"
schema.3768180960.required: "false"
schema.3768180960.string_attribute_constraints.#: "0"
verification_message_template.#: "1"
verification_message_template.0.default_email_option: "CONFIRM_WITH_CODE"
verification_message_template.0.email_message: <computed>
verification_message_template.0.email_message_by_link: <computed>
verification_message_template.0.email_subject: <computed>
verification_message_template.0.email_subject_by_link: <computed>
verification_message_template.0.sms_message: <computed>
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
aws_cognito_user_pool.pankajk_security: Creating...
admin_create_user_config.#: "" => "<computed>"
alias_attributes.#: "" => "2"
alias_attributes.1888159429: "" => "preferred_username"
alias_attributes.881205744: "" => "email"
arn: "" => "<computed>"
auto_verified_attributes.#: "" => "1"
auto_verified_attributes.881205744: "" => "email"
creation_date: "" => "<computed>"
email_verification_message: "" => "Please use the following code: {####}"
email_verification_subject: "" => "Your Verification Code"
lambda_config.#: "" => "<computed>"
last_modified_date: "" => "<computed>"
mfa_configuration: "" => "OFF"
name: "" => "pankajk-security"
password_policy.#: "" => "1"
password_policy.0.minimum_length: "" => "10"
password_policy.0.require_lowercase: "" => "true"
password_policy.0.require_numbers: "" => "true"
password_policy.0.require_symbols: "" => "true"
password_policy.0.require_uppercase: "" => "true"
schema.#: "" => "2"
schema.1734507539.attribute_data_type: "" => "String"
schema.1734507539.developer_only_attribute: "" => "false"
schema.1734507539.mutable: "" => "true"
schema.1734507539.name: "" => "email"
schema.1734507539.number_attribute_constraints.#: "" => "0"
schema.1734507539.required: "" => "true"
schema.1734507539.string_attribute_constraints.#: "" => "1"
schema.1734507539.string_attribute_constraints.0.max_length: "" => "256"
schema.1734507539.string_attribute_constraints.0.min_length: "" => "7"
schema.3768180960.attribute_data_type: "" => "String"
schema.3768180960.developer_only_attribute: "" => "false"
schema.3768180960.mutable: "" => "true"
schema.3768180960.name: "" => "oid"
schema.3768180960.number_attribute_constraints.#: "" => "1"
schema.3768180960.number_attribute_constraints.0.max_value: "" => "256"
schema.3768180960.number_attribute_constraints.0.min_value: "" => "1"
schema.3768180960.required: "" => "false"
schema.3768180960.string_attribute_constraints.#: "" => "0"
verification_message_template.#: "" => "1"
verification_message_template.0.default_email_option: "" => "CONFIRM_WITH_CODE"
verification_message_template.0.email_message: "" => "<computed>"
verification_message_template.0.email_message_by_link: "" => "<computed>"
verification_message_template.0.email_subject: "" => "<computed>"
verification_message_template.0.email_subject_by_link: "" => "<computed>"
verification_message_template.0.sms_message: "" => "<computed>"
aws_cognito_user_pool.pankajk_security: Creation complete after 3s (ID: us-west-2_t6jMrbPx1)
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
$ terraformãã©ã³
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
aws_cognito_user_pool.pankajk_security: Refreshing state... (ID: us-west-2_t6jMrbPx1)
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement
Terraform will perform the following actions:
-/+ aws_cognito_user_pool.pankajk_security (new resource required)
id: "us-west-2_t6jMrbPx1" => <computed> (forces new resource)
admin_create_user_config.#: "1" => <computed>
alias_attributes.#: "2" => "2"
alias_attributes.1888159429: "preferred_username" => "preferred_username"
alias_attributes.881205744: "email" => "email"
arn: "arn:aws:cognito-idp:us-west-2:166326852216:userpool/us-west-2_t6jMrbPx1" => <computed>
auto_verified_attributes.#: "1" => "1"
auto_verified_attributes.881205744: "email" => "email"
creation_date: "2018-04-18T18:11:08Z" => <computed>
email_verification_message: "Please use the following code: {####}" => "Please use the following code: {####}"
email_verification_subject: "Your Verification Code" => "Your Verification Code"
lambda_config.#: "0" => <computed>
last_modified_date: "2018-04-18T18:11:08Z" => <computed>
mfa_configuration: "OFF" => "OFF"
name: "pankajk-security" => "pankajk-security"
password_policy.#: "1" => "1"
password_policy.0.minimum_length: "10" => "10"
password_policy.0.require_lowercase: "true" => "true"
password_policy.0.require_numbers: "true" => "true"
password_policy.0.require_symbols: "true" => "true"
password_policy.0.require_uppercase: "true" => "true"
schema.#: "2" => "2"
schema.1734507539.attribute_data_type: "String" => "String"
schema.1734507539.developer_only_attribute: "false" => "false"
schema.1734507539.mutable: "true" => "true"
schema.1734507539.name: "email" => "email"
schema.1734507539.number_attribute_constraints.#: "0" => "0"
schema.1734507539.required: "true" => "true"
schema.1734507539.string_attribute_constraints.#: "1" => "1"
schema.1734507539.string_attribute_constraints.0.max_length: "256" => "256"
schema.1734507539.string_attribute_constraints.0.min_length: "7" => "7"
schema.3768180960.attribute_data_type: "" => "String" (forces new resource)
schema.3768180960.developer_only_attribute: "" => "false" (forces new resource)
schema.3768180960.mutable: "" => "true" (forces new resource)
schema.3768180960.name: "" => "oid" (forces new resource)
schema.3768180960.number_attribute_constraints.#: "" => "1" (forces new resource)
schema.3768180960.number_attribute_constraints.0.max_value: "" => "256" (forces new resource)
schema.3768180960.number_attribute_constraints.0.min_value: "" => "1" (forces new resource)
schema.3768180960.required: "" => "false" (forces new resource)
schema.3768180960.string_attribute_constraints.#: "" => "0"
schema.383977790.attribute_data_type: "String" => "" (forces new resource)
schema.383977790.developer_only_attribute: "false" => "false"
schema.383977790.mutable: "true" => "false" (forces new resource)
schema.383977790.name: "oid" => "" (forces new resource)
schema.383977790.number_attribute_constraints.#: "0" => "0"
schema.383977790.required: "false" => "false"
schema.383977790.string_attribute_constraints.#: "1" => "0" (forces new resource)
schema.383977790.string_attribute_constraints.0.max_length: "" => ""
schema.383977790.string_attribute_constraints.0.min_length: "" => ""
verification_message_template.#: "1" => "1"
verification_message_template.0.default_email_option: "CONFIRM_WITH_CODE" => "CONFIRM_WITH_CODE"
verification_message_template.0.email_message: "Please use the following code: {####}" => <computed>
verification_message_template.0.email_message_by_link: "" => <computed>
verification_message_template.0.email_subject: "Your Verification Code" => <computed>
verification_message_template.0.email_subject_by_link: "" => <computed>
verification_message_template.0.sms_message: "" => <computed>
Plan: 1 to add, 0 to change, 1 to destroy.
------------------------------------------------------------------------
Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.
@pankajkuããªããçŽé¢ããŠããåé¡ã¯ç°ãªããŸãã ãã ããIMHOãã©ãã©ãŒã ã¯ãã®ãããªãšã©ãŒããã£ããã§ããã¯ãã§ãã
æ§æã«ãšã©ãŒããããŸãã oid
å Žåã attribute_data_type = "String"
æå®ããŸããã number_attribute_constraints
æå®ããŸããä¿®æ£ãããæ§æã¯æ¬¡ã®ãšããã§ãã
variable "region" {
default = "us-east-1"
}
provider "aws" {
version = "1.14.1"
region = "${var.region}"
}
resource "aws_cognito_user_pool" "pankajk_security" {
name = "pankajk-security"
email_verification_subject = "Your Verification Code"
email_verification_message = "Please use the following code: {####}"
alias_attributes = ["email", "preferred_username"]
auto_verified_attributes = ["email"]
verification_message_template {
default_email_option = "CONFIRM_WITH_CODE"
}
password_policy {
minimum_length = 10
require_lowercase = true
require_numbers = true
require_symbols = true
require_uppercase = true
}
schema {
attribute_data_type = "String"
developer_only_attribute = false
mutable = true
name = "email"
required = true
string_attribute_constraints {
min_length = 7
max_length = 256
}
}
schema {
attribute_data_type = "String"
developer_only_attribute = false
mutable = true
name = "oid"
required = false
string_attribute_constraints {
min_length = 1
max_length = 256
}
}
}
@ Puneeth-nãç§ã®èšå®ã§åé¡ãèŠã€ããŠãããŠããããšãã ç§ã¯ããªãã®ææ¡ã«åŸã£ãŠãããå€æŽããŸããããããŠä»ãã©ãã©ãŒã ã¯å€æŽãããå±æ§ã ããæŽæ°ããŸãã
èšå®ãã¡ã€ã«ã«ç°¡åãªå€æŽïŒæ€èšŒã¡ãã»ãŒãžããã¹ããªã©ïŒãå ããŠãterraformapplyããå®è¡ãããšãé»åã¡ãŒã«æ€èšŒãã©ã°ãèšå®ãããŠããªãããšã«æ°ä»ããŸããã
$ãã©ãã©ãŒã ãé©çšãããŸã
aws_cognito_user_pool.pankajk_security: Refreshing state... (ID: us-west-2_LKVhvfWsH)
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
~ aws_cognito_user_pool.pankajk_security
email_verification_subject: "Your verification code" => "Your Verification Code"
Plan: 0 to add, 1 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
aws_cognito_user_pool.pankajk_security: Modifying... (ID: us-west-2_LKVhvfWsH)
email_verification_subject: "Your verification code" => "Your Verification Code"
aws_cognito_user_pool.pankajk_security: Modifications complete after 1s (ID: us-west-2_LKVhvfWsH)
Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
$ãã©ãã©ãŒã ãã©ã³
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
aws_cognito_user_pool.pankajk_security: Refreshing state... (ID: us-west-2_LKVhvfWsH)
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
~ aws_cognito_user_pool.pankajk_security
auto_verified_attributes.#: "0" => "1"
auto_verified_attributes.881205744: "" => "email"
Plan: 0 to add, 1 to change, 0 to destroy.
------------------------------------------------------------------------
Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.
ãããèšå®ãã¡ã€ã«ã®ãšã©ãŒã«ãããã®ãªã®ãããã°ã«ãããã®ãªã®ãçåã«æããŸãã
ããã¯ãŸã åé¡ã®ããã§ãããtfããŠãŒã¶ãŒããŒã«ãåé€ãããã¹ãŠã®ãŠãŒã¶ãŒã倱ããšãããæ¥èª°ãã«å€ãã®å¿çãåŒãèµ·ããã§ããã...
ãããã¹ããŒãã«è¿œå ãããšãã³ã³ãœãŒã«/ CLIã§ç Žæ£ããã«äœæã§ããã«ããããããããŠãŒã¶ãŒããŒã«ãç Žæ£ãããŸãã
{
name = "foo"
attribute_data_type = "String"
mutable = true
developer_only_attribute = "false"
required = "false"
string_attribute_constraints = {
min_length = 0
max_length = 256
}
},
ããã pool
ãšclient
äž¡æ¹ã«prevent_destroy
èšå®ããŠããŸã
æ°ããã«ã¹ã¿ã å±æ§ãè¿œå ããããšãããšããªãœãŒã¹ã®åäœæã®åé¡ãçºçããŸãã
TerraformããŒãžã§ã³
Terraform v0.11.8
Provider.aws v1.36.0
æ°ããã«ã¹ã¿ã å±æ§ãè¿œå ããå
resource "aws_cognito_user_pool" "pool" {
name = "Test"
username_attributes = ["email"]
auto_verified_attributes = ["email"]
schema = [
{
attribute_data_type = "String"
developer_only_attribute = false
mutable = false
name = "email"
required = true
string_attribute_constraints = {
min_length = 1
max_length = 256
}
},
{
attribute_data_type = "String"
developer_only_attribute = false
mutable = true
name = "custom1"
required = false
string_attribute_constraints = {
min_length = 0
max_length = 256
}
}
]
}
æ°ããã«ã¹ã¿ã å±æ§ãè¿œå ãã
{
attribute_data_type = "String"
developer_only_attribute = false
mutable = true
name = "custom2"
required = false
string_attribute_constraints = {
min_length = 0
max_length = 256
}
}
ãããã°åºå
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement
Terraform will perform the following actions:
-/+ aws_cognito_user_pool.pool (new resource required)
...
lambda_config.#: "0" => <computed>
last_modified_date: "2018-09-19T03:33:52Z" => <computed>
mfa_configuration: "OFF" => "OFF"
name: "Test" => "Test"
password_policy.#: "1" => <computed>
schema.#: "2" => "3" (forces new resource)
schema.2766842814.attribute_data_type: "" => "String" (forces new resource)
schema.2766842814.developer_only_attribute: "" => "false" (forces new resource)
schema.2766842814.mutable: "" => "true" (forces new resource)
schema.2766842814.name: "" => "custom2" (forces new resource)
schema.2766842814.number_attribute_constraints.#: "" => "0"
schema.2766842814.required: "" => "false" (forces new resource)
schema.2766842814.string_attribute_constraints.#: "" => "1" (forces new resource)
schema.2766842814.string_attribute_constraints.0.max_length: "" => "256" (forces new resource)
schema.2766842814.string_attribute_constraints.0.min_length: "" => "0" (forces new resource)
schema.3686385984.attribute_data_type: "String" => "String"
schema.3686385984.developer_only_attribute: "false" => "false"
schema.3686385984.mutable: "false" => "false"
schema.3686385984.name: "email" => "email"
schema.3686385984.number_attribute_constraints.#: "0" => "0"
schema.3686385984.required: "true" => "true"
schema.3686385984.string_attribute_constraints.#: "1" => "1"
schema.3686385984.string_attribute_constraints.0.max_length: "256" => "256"
schema.3686385984.string_attribute_constraints.0.min_length: "1" => "1"
schema.893709367.attribute_data_type: "String" => "String"
schema.893709367.developer_only_attribute: "false" => "false"
schema.893709367.mutable: "true" => "true"
schema.893709367.name: "custom1" => "custom1"
schema.893709367.number_attribute_constraints.#: "0" => "0"
schema.893709367.required: "false" => "false"
schema.893709367.string_attribute_constraints.#: "1" => "1"
schema.893709367.string_attribute_constraints.0.max_length: "256" => "256"
schema.893709367.string_attribute_constraints.0.min_length: "0" => "0"
username_attributes.#: "1" => "1"
username_attributes.0: "email" => "email"
verification_message_template.#: "1" => <computed>
Plan: 1 to add, 0 to change, 1 to destroy.
åèïŒ string_attribute_constraints
ããã«ã«ã¹ã¿ã å±æ§ãäœæãããšãããåããã°ãçºçããŸããã
schema {
name = "custom_id"
required = false
attribute_data_type = "String"
developer_only_attribute = false
mutable = true
}
空ã®string_attribute_constraints
ãè¿œå ããåŸããã®ãã°ãåé¿ã§ããŸããã
schema {
name = "custom_id"
required = false
attribute_data_type = "String"
developer_only_attribute = false
mutable = true
string_attribute_constraints {}
}
çããã®åé¿çã«æ¬åœã«æè¬ããŠããŸãïŒ
åé¿çã¯ç§ã«ã¯ããŸããããŸããã
schema {
attribute_data_type = "String"
developer_only_attribute = false
mutable = true
name = "parent_id"
required = false
string_attribute_constraints {
min_length = 1
max_length = 256
}
}
ãã©ã³ïŒ
schema.#: "10" => "11" (forces new resource)
schema.2272806367.attribute_data_type: "" => "String" (forces new resource)
schema.2272806367.developer_only_attribute: "" => "false" (forces new resource)
schema.2272806367.mutable: "" => "false" (forces new resource)
schema.2272806367.name: "" => "parent_id" (forces new resource)
schema.2272806367.number_attribute_constraints.#: "" => "0"
schema.2272806367.required: "" => "false" (forces new resource)
schema.2272806367.string_attribute_constraints.#: "" => "1" (forces new resource)
schema.2272806367.string_attribute_constraints.0.max_length: "" => "256" (forces new resource)
schema.2272806367.string_attribute_constraints.0.min_length: "" => "1" (forces new resource)
ããŒãžã§ã³ïŒ
Terraform v0.11.11
+ provider.archive v1.1.0
+ provider.aws v1.52.0
ããã¯ãæ°ããã¢ããªã±ãŒã·ã§ã³ãéçºããŠããŠãã«ã¹ã¿ã å±æ§ãè¿œå /å®éšããå¿ èŠããã人ã«ãšã£ãŠã¯å€§ããªåé¡ã§ãã ãã®ãããããŒã«ã10å以äžç Žå£ãããŸããã
ããã«ã€ããŠäœãé²å±ã¯ãããŸããïŒ çããã¯ããã¹ã¯ãŒãããªã»ããããããã«é¡§å®¢ã«äŸé Œããããšãå«ããªãœãŒã¹ãå¹ãé£ã°ãããšã匷å¶ããŠããŸãïŒæåã«ã€ã³ããŒãããããã¯ã¢ããããŒã¿ãããããšä»®å®ããŸãïŒããŸãã¯ç§ã«ãšã£ãŠã¯ãã©ã€ããµã€ã¯ã«ignore_changes *ãèšå®ãã誰ããæçµçã«åé¿ããããšãé¡ã£ãŠããŸãå¥ã®å€æŽãå¿ èŠã«ãªãåã«ãããä¿®æ£ããŸãã
ããã9ãæéç¶ããŠãããšããäºå®ã¯ãTerraformã«ãšã£ãŠéèŠãªã€ã³ãã©ã¹ãã©ã¯ãã£ãä¿¡é Œãã¹ããã©ãããçå£ã«èããããŠããŸãã
åé¿çãç§ã«ã¯ããŸããããŸããã ãã³ãã¬ãŒãã«å€æŽããªãå Žåã§ããåžžã«ããŒã«ãåäœæãããŸãã
> terraform --version
Terraform v0.11.11
+ provider.archive v1.1.0
+ provider.aws v1.54.0
ãŸã åé¡
Terraform v0.11.11
+ provider.aws v1.57.0
ãããŠãªã...
Terraform v0.11.11
+ provider.aws v1.59.0
ç§ãããã«åœ±é¿ãããŸããåé¿çã®ã©ããç§ã®ããã«åããŸããã§ããã
Terraform v0.11.11
+ provider.aws v1.60.0
ããã9ãæéç¶ããŠãããšããäºå®ã¯ãTerraformã«ãšã£ãŠéèŠãªã€ã³ãã©ã¹ãã©ã¯ãã£ãä¿¡é Œãã¹ããã©ãããçå£ã«èããããŠããŸãã
ç§ã¯èªåèªèº«ã«åã質åãããŠããŸãã 1幎以äžåŠçãããŠããªãé倧ãªãã°ãããããããã2幎以äžåŠçãããŠããªããã®ããããŸãã ãããã®ãã°ã®å€ãã«ã€ããŠã¯ãæºåãæŽã£ãPRããããããã1幎以äžã«ããã£ãŠè§£ãæŸãããŠããŸãã
ãŸãæè¿ãç§ã¯æ·±å»ãªãã°ã¬ããŒããèšå ¥ããŸããããjsonencodeé¢æ°ã§-圌ãã¯ããããã£ãºããããšãæåŠããŸããã è¿ä¿¡ã¯-ããŒãžã§ã³12ã§ä¿®æ£ãããŠãããå°æ¥çã«ã¯äžæãªææã«ãªãªãŒã¹ãããäºå®ã§ãããããŒãžã§ã³11ã«ã€ããŠã¯æ°ã«ããŸããã
ãšããã§ããã®ãããã¯ã®åé¡ã¯ãcognitoãŠãŒã¶ãŒããŒã«ãæã£ãŠããå¯äžã®åé¡ã§ã¯ãããŸããã Callback_urlsã¯ãAWSããããè¡ãã®ãšãŸã£ããåãããã«é åºä»ãããå¿ èŠããããŸããããããªããšãterraformã¯åžžã«é åºãå€æŽããããšããŸãã
@voroniys 3幎以äžTerraformã䜿çšããããšããã®ç§ã®æã¡åž°ãã¯ãTerraformãä»ããŠç¶æ ãç¶æããããšã§ã¯ãããŸããã ããã¯ã©ã®IaCã«ãåœãŠã¯ãŸããŸãã Terraformã¯åŒ·åãªããŒã«ã§ãããç¥ã«ã¢ã¯ã»ã¹ã§ããŸãã ç¶æ ã®ããã¢ããªã±ãŒã·ã§ã³ã«ã¯äœ¿çšããªãã§ãã ããã
ãŸã åé¡ã§ãã
ç§ã¯ããã調æ»ããããããä¿®æ£ãããæ¹æ³ãèŠã€ããŠããŸãã
ã«ã¹ã¿ã å±æ§ã®ç®¡çãå¯èœã«ããããã®ããè¯ãæ¹æ³ã¯ãã«ã¹ã¿ã å±æ§ãå¥ã®ãªãœãŒã¹ïŒããšãã°ã aws_cognito_user_pool_schema_custom_attribute
ã§ãã
Terraformã§ã¯ããªãœãŒã¹ã¯ãCreateãReadãUpdateãããã³Deleteé¢æ°ã®ã³ãŒã«ããã¯ãšãšãã«ã¹ããŒãã«ãã£ãŠå®çŸ©ãããŸãã Core Terraformã¯ãçŸåšã®ç¶æ ãšTerraformã³ãŒãã§å®çŸ©ãããã®ãšã®å·®ãèšç®ããŸãã ç§ãã¡ã¯ãTFãæ£ããããšãããããšã«å¯èœãªéãäŸåããããšæã£ãŠããŸãã
ã¹ããŒãå±æ§ãåå¥ã®ãªãœãŒã¹ãšããŠåé€ãããšãå·®ç°ã®èšç®ããããã现ããå¶åŸ¡ã§ããŸããæ°ããã«ã¹ã¿ã ã¹ããŒãå±æ§ãªãœãŒã¹ãè¿œå ãããšãTerraformã¯ãã®Destroy / Createã·ãŒã±ã³ã¹ã§ã¯ãªããåå¥ã®ãªãœãŒã¹ã®Createé¢æ°ãåŒã³åºããŸããããŒã«ã ã¹ããŒãå±æ§ãªãœãŒã¹ã®Createé¢æ°ã§ãAWS Cognito AddCustomAttributes
APIåŒã³åºããåŒã³åºãããšãã§ããŸãã
ã¹ããŒãå±æ§ã®ããããã£ãžã®å€æŽããããã现ããåŠçã§ããŸãããããã¯ãã¹ãããå¿ èŠããããŸãã
ïŒèª€ã£ãŠïŒTerraformã³ãŒãããã«ã¹ã¿ã ã¹ããŒãå±æ§ãªãœãŒã¹ãåé€ãããšãTFã¯å±æ§ãªãœãŒã¹ã®åé€æ©èœãåŒã³åºããŸãã åé€ããµããŒããããŠããããTFã³ãŒãã埩å ããå¿ èŠãããããšã瀺ããšã©ãŒãçºçããå¯èœæ§ããããŸãã
ã³ã¡ã³ãïŒ
@bflad ãå€æŽã®èšèšã誰ãæäŒã£ãŠããããç¥ã£ãŠããŸããïŒ
ããªãã®ä»äºãšææ¡ãããããšã@ringods ã ããã¯ããã®åé¡ã«åãçµãããã®æ£ããéãããããŸããïŒ
ä»æ¥ã®æç¹ã§ææ°ããŒãžã§ã³ã䜿çšããŠããéãåé¡ãæ€èšŒããŠããŸãïŒ
Terraform v0.12.3
+ provider.aws v2.18.0
ç°¡åãªèŠçŽïŒ
resource "aws_cognito_user_pool" "pool" {
name = "mypooltest2"
}
次ã«ãå±æ§ãè¿œå ããŸãã
resource "aws_cognito_user_pool" "pool" {
name = "mypooltest2"
schema {
attribute_data_type = "String"
name = "email"
required = true
}
}
Terraformã¯ãæ¬æ¥ã®ããã«ã€ã³ã¯ãªã¡ã³ã¿ã«æŽæ°ãè¡ãã®ã§ã¯ãªãããªãœãŒã¹ãç Žæ£ããŠããå床远å ããŸãã
Plan: 1 to add, 0 to change, 1 to destroy.
æ°ããæ©èœãæ¬çªç°å¢ã«ãããã€ããããšã«åºå·ããŠããŸããæ°ããã«ã¹ã¿ã å±æ§ãè¿œå ããå¿ èŠããããŸããCLIã䜿çšããŠè¿œå ãããšãä»ã®å€ãã®ãªãœãŒã¹ããããã©ãã©ãŒã æ§æå šäœãå°ç¡ãã«ãªããŸãã
@ringodsã®ææ¡ã¯ãæ¢åã®tfæ§æãäžæããããšãªããç§ãã¡ã®ããã«æ©èœããå¯èœæ§ããããŸãã ãããã£ãŠããã®ãœãªã¥ãŒã·ã§ã³ã«è²¢ç®ããããšããŠããŸãã
ãããç§ã®ã³ãŒãã®æåã®ãã©ããã§ãã ããŒã«ã«ã§æ§ç¯ãããterraform-provider-awsããã€ã³ãããŠãã¹ãããããšã«æåããŸããã ç§ã¯ä»ãåãå
¥ããã¹ããæžããŠããŸãã PRã«é¢ããææ¡/ã³ã¡ã³ããããã ããã°å¹žãã§ãã
次ã®æ¹æ³ã§ããŠãŒã¶ãŒããŒã«ã倱ãããšãªãcognitoã«å±æ§ãè¿œå ããŸããã
aws cognito-idp --region ... add-custom-attributes --user-pool-id ... --custom-attributes Name=...,AttributeDataType=Boolean,DeveloperOnlyAttribute=false, Mutable=true,Required=false
terraform state rm aws_cognito_user_pool.main
terraform import aws_cognito_user_pool.main ...
ãã®å ŽåããªãœãŒã¹ãç¶æ ãããã³main.tfãã¡ã€ã«ãäžèŽããŸããã æåã«éçºç°å¢ãè©ŠããŠã¿ãããšããå§ãããŸããããã圹ç«ã€ããšãé¡ã£ãŠããŸãã
ãããä¿®æ£ããŠãã ããïŒ ePoromaaã®åé¿çãå®è¡ããããšã¯ãç¶æ ãæåã§ç®¡çããªããã°ãªããªãã®ã¯ã°ãããŠããŸãã
ããã«ã€ããŠã¯ãŸã é²å±ããããŸããïŒ ãã©ãã©ãŒã ç¶æ ãæåã§æäœããå¿ èŠã®ãªããœãªã¥ãŒã·ã§ã³ãå¿åŸ ã¡ã«ããŠããŸãã :-)
pingãã ç¶æ ãæåã§ç®¡çããã®ã¯...ã°ãããŠããŸã
ã¿ããªãæŽæ°ã¯ãããŸããïŒ ç§ãã¡ã¯ä»2020幎ã«ããŸã...
ã¯ãããŸã åé¡ã§ã...
ãããä»ã®ãã¹ãŠã®äººã«åœ¹ç«ã€ããšãé¡ã£ãŠããŸããäžèšã®è§£æ±ºçãããç°¡åãªæ¹æ³ã§ããããã©ãã©ãŒã ã®ç¶æ ãšã€ã³ããŒããããããããæ··ä¹±ãå°ãªãå¯èœæ§ããããŸãã
ePoromaaãšåæ§ã«ãaws cli cmdãæåã§å®è¡ããŠãã«ã¹ã¿ã å±æ§ãcognitoãŠãŒã¶ãŒããŒã«ã«è¿œå ããå¿
èŠããããŸãã
aws cognito-idp add-custom-attributes --user-pool-id us-west-2_aaaaaaaaa --custom-attributes Name="CustomAttr1",AttributeDataType="String",DeveloperOnlyAttribute=false,Required=false,StringAttributeConstraints="{MinLength=1,MaxLength=15}"
å©çšå¯èœãªå±æ§ã®è©³çŽ°ã«ã€ããŠã¯ã https ïŒ
aws cliãä»ããŠã«ã¹ã¿ã å±æ§ãè¿œå ãããã次ã«ããã®ã¹ããŒããããã¯ãterraformcognitoãŠãŒã¶ãŒããŒã«ã³ãŒãã«è¿œå ããå¿ èŠããããŸãã äŸãã°
schema {
name = "CustomAttr1"
attribute_data_type = "String"
required = false
developer_only_attribute = false
string_attribute_constraints {
min_length = 1
max_length = 15
}
}
ã¹ããŒããããã¯ãterraformã«è¿œå ããããšãterraformã¯å€æŽãååŸããŸããã ããã¯æ¬çªç°å¢ã§ãå®å šã ãšæããŸãã
Terraform v0.12.26
ãŸã åé¡ããããŸã...
ã¿ãªãããããã«ã¡ã¯ãããã§ã®æŽæ°ã¯ãããŸããïŒ
ãã®åé¡ãä¿®æ£ããŠãã ããïŒ
ããã¯ãŸã åé¡ã§ã
Terraform v0.12.28
+ provider.aws v2.67.0
察åŠããŠãã ããã
ãŠãŒã¶ãŒããŒã«ã®ç Žå£ãé²ãããã®åé¿çïŒ
1ïŒã³ã³ãœãŒã«ãŸãã¯CLIãä»ããŠã«ã¹ã¿ã å±æ§ãè¿œå ããŸãã
2ïŒäœæããå±æ§ãšããããæ¹æ³ã§åäžã®ãã©ãã©ãŒã ãã³ãã¬ãŒãã«ã¹ããŒããããã¯ãè¿œå ããŸãã
3ïŒãã©ãã©ãŒã ãªãã¬ãã·ã¥ãå®è¡ããŸãã ã¹ããŒããåæ ããããã«ç¶æ
ãã¡ã€ã«ãæŽæ°ããå¿
èŠããããŸãã
4ïŒterraformèšç»ãå®è¡ããŠããŠãŒã¶ãŒããŒã«ãç Žå£ãããŠããªãããšã確èªããŸãã
ããã«ã¡ã¯ãç§ãã¡ããã®åé¡ã«çŽé¢ããŠããŸãã æŽæ°ã¯ãããŸããïŒ ããããšãïŒ
HashiCorpã®äººã¯ããŸããïŒ ããã«ã¡ã¯....
ããã«ãçŽé¢ããŠããŸãïŒ
Terraform v0.12.29
Terraform v0.13.3
ãŸã åé¡ã«çŽé¢ããŠãã
ããã«ã¡ã¯ãã¿ããªïŒ ïŒwaveïŒãã®ã¢ã€ãã ãèšåãããŠãããã®ååæïŒ11æãã1æïŒã®å ¬éããŒããããã玹ä»ããããšæããŸãã
ãã®åé¡ã®è§£æ±ºã«å¯Ÿããã³ãã¥ããã£ã®å€§ããªé¢å¿ã®ãããæ¢åã®è²¢ç®ããŸããªãçµ±åããããšãæ€èšããŠããŸãã
ãããŸã§ã®ãã¹ãŠã®è²¢ç®ãšãã£ãŒãããã¯ã«æè¬ããŸãã
æãåèã«ãªãã³ã¡ã³ã
ããã«ã€ããŠäœãé²å±ã¯ãããŸããïŒ çããã¯ããã¹ã¯ãŒãããªã»ããããããã«é¡§å®¢ã«äŸé Œããããšãå«ããªãœãŒã¹ãå¹ãé£ã°ãããšã匷å¶ããŠããŸãïŒæåã«ã€ã³ããŒãããããã¯ã¢ããããŒã¿ãããããšä»®å®ããŸãïŒããŸãã¯ç§ã«ãšã£ãŠã¯ãã©ã€ããµã€ã¯ã«ignore_changes *ãèšå®ãã誰ããæçµçã«åé¿ããããšãé¡ã£ãŠããŸãå¥ã®å€æŽãå¿ èŠã«ãªãåã«ãããä¿®æ£ããŸãã
ããã9ãæéç¶ããŠãããšããäºå®ã¯ãTerraformã«ãšã£ãŠéèŠãªã€ã³ãã©ã¹ãã©ã¯ãã£ãä¿¡é Œãã¹ããã©ãããçå£ã«èããããŠããŸãã