Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r/cognito_user_pool_client - adjust token validity validation #19702

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changelog/19702.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:enhancement
resource/aws_cognito_user_pool_client: Add plan time validation for `id_token_validity` and `access_token_validity`.
```

```release-note:bug
resource/aws_cognito_user_pool_client: Fix plan time validation for `refresh_token_validity`
```
12 changes: 7 additions & 5 deletions aws/resource_aws_cognito_user_pool_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ func resourceAwsCognitoUserPoolClient() *schema.Resource {
// https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_CreateUserPoolClient.html
Schema: map[string]*schema.Schema{
"access_token_validity": {
Type: schema.TypeInt,
Optional: true,
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(0, 86400),
},
"allowed_oauth_flows": {
Type: schema.TypeSet,
Expand Down Expand Up @@ -133,8 +134,9 @@ func resourceAwsCognitoUserPoolClient() *schema.Resource {
ForceNew: true,
},
"id_token_validity": {
Type: schema.TypeInt,
Optional: true,
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntBetween(0, 86400),
},
"logout_urls": {
Type: schema.TypeSet,
Expand Down Expand Up @@ -175,7 +177,7 @@ func resourceAwsCognitoUserPoolClient() *schema.Resource {
Type: schema.TypeInt,
Optional: true,
Default: 30,
ValidateFunc: validation.IntBetween(0, 3650),
ValidateFunc: validation.IntBetween(0, 315360000),
},
"supported_identity_providers": {
Type: schema.TypeSet,
Expand Down
18 changes: 9 additions & 9 deletions aws/resource_aws_cognito_user_pool_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -761,15 +761,15 @@ data "aws_caller_identity" "current" {}
data "aws_partition" "current" {}

resource "aws_cognito_user_pool" "test" {
name = "%[1]s"
name = %[1]q
}

resource "aws_pinpoint_app" "test" {
name = "%[2]s"
name = %[2]q
}

resource "aws_iam_role" "test" {
name = "%[2]s"
name = %[2]q

assume_role_policy = <<EOF
{
Expand All @@ -789,7 +789,7 @@ EOF
}

resource "aws_iam_role_policy" "test" {
name = "%[2]s"
name = %[2]q
role = aws_iam_role.test.id

policy = <<-EOF
Expand All @@ -814,12 +814,12 @@ EOF
func testAccAWSCognitoUserPoolClientConfigAnalyticsConfig(userPoolName, clientName string) string {
return testAccAWSCognitoUserPoolClientConfigAnalyticsConfigBase(userPoolName, clientName) + fmt.Sprintf(`
resource "aws_cognito_user_pool_client" "test" {
name = "%[1]s"
name = %[1]q
user_pool_id = aws_cognito_user_pool.test.id

analytics_configuration {
application_id = aws_pinpoint_app.test.application_id
external_id = "%[1]s"
external_id = %[1]q
role_arn = aws_iam_role.test.arn
}
}
Expand All @@ -829,12 +829,12 @@ resource "aws_cognito_user_pool_client" "test" {
func testAccAWSCognitoUserPoolClientConfigAnalyticsConfigShareUserData(userPoolName, clientName string) string {
return testAccAWSCognitoUserPoolClientConfigAnalyticsConfigBase(userPoolName, clientName) + fmt.Sprintf(`
resource "aws_cognito_user_pool_client" "test" {
name = "%[1]s"
name = %[1]q
user_pool_id = aws_cognito_user_pool.test.id

analytics_configuration {
application_id = aws_pinpoint_app.test.application_id
external_id = "%[1]s"
external_id = %[1]q
role_arn = aws_iam_role.test.arn
user_data_shared = true
}
Expand All @@ -845,7 +845,7 @@ resource "aws_cognito_user_pool_client" "test" {
func testAccAWSCognitoUserPoolClientConfigAnalyticsWithArnConfig(userPoolName, clientName string) string {
return testAccAWSCognitoUserPoolClientConfigAnalyticsConfigBase(userPoolName, clientName) + fmt.Sprintf(`
resource "aws_cognito_user_pool_client" "test" {
name = "%[1]s"
name = %[1]q
user_pool_id = aws_cognito_user_pool.test.id

analytics_configuration {
Expand Down