Skip to content

Commit

Permalink
Pull request #1025: Log group trigger deprecation
Browse files Browse the repository at this point in the history
Merge in CLOUD/terraform-provider-yandex-mirror from log_group_trigger_deprecation to master

Squashed commit of the following:

commit 4846ad5ebb5660f7a5fc826b859c2eeac6069e2e
Author: Sergey Dubovtsev <[email protected]>
Date:   Tue Nov 7 04:22:53 2023 +0300

    log_group trigger deprecation
  • Loading branch information
Sergey Dubovtsev committed Nov 17, 2023
1 parent 010a209 commit 51b2bbc
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 96 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ ENHANCEMENTS:
BUG FIXES:
* yandex_ydb_database: Add additional wait duration after database was created

FEATURES:
* serverless: `log_group` trigger is deprecated. Use `logging` trigger instead.

## 0.102.0 (November 8, 2023)

FEATURES:
Expand Down
1 change: 0 additions & 1 deletion yandex/data_source_yandex_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ func TestAccDataSourceYandexFunction_full(t *testing.T) {
testYandexFunctionContainsTag(functionDataSource, params.tags),
resource.TestCheckResourceAttrSet(functionDataSource, "version"),
resource.TestCheckResourceAttrSet(functionDataSource, "image_size"),
resource.TestCheckResourceAttrSet(functionDataSource, "loggroup_id"),
resource.TestCheckResourceAttrSet(functionDataSource, "secrets.0.id"),
resource.TestCheckResourceAttrSet(functionDataSource, "secrets.0.version_id"),
resource.TestCheckResourceAttr(functionDataSource, "secrets.0.key", params.secret.secretKey),
Expand Down
1 change: 0 additions & 1 deletion yandex/resource_yandex_function_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ func TestAccYandexFunction_full(t *testing.T) {
testYandexFunctionContainsTag(functionResource, params.tags),
resource.TestCheckResourceAttrSet(functionResource, "version"),
resource.TestCheckResourceAttrSet(functionResource, "image_size"),
resource.TestCheckResourceAttrSet(functionResource, "loggroup_id"),
resource.TestCheckResourceAttrSet(functionResource, "secrets.0.id"),
resource.TestCheckResourceAttrSet(functionResource, "secrets.0.version_id"),
resource.TestCheckResourceAttr(functionResource, "secrets.0.key", params.secret.secretKey),
Expand Down
94 changes: 0 additions & 94 deletions yandex/resource_yandex_function_trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,48 +275,6 @@ func TestAccYandexFunctionTrigger_object(t *testing.T) {
})
}

func TestAccYandexFunctionTrigger_loggroup(t *testing.T) {
t.Parallel()

trigger := &triggers.Trigger{}
triggerName := acctest.RandomWithPrefix("tf-trigger")
logSrcFn := &functions.Function{}
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testYandexFunctionTriggerDestroy,
Steps: []resource.TestStep{
{
Config: testYandexFunctionTriggerLogGroup(triggerName, 5, 100),
Check: resource.ComposeTestCheckFunc(
testYandexFunctionTriggerExists(triggerResource, trigger),
resource.TestCheckResourceAttr(triggerResource, "name", triggerName),
resource.TestCheckResourceAttrSet(triggerResource, "function.0.id"),
testYandexFunctionExists("yandex_function.log-src-fn", logSrcFn),
resource.TestCheckResourceAttr(triggerResource, "log_group.0.batch_cutoff", "5"),
resource.TestCheckResourceAttr(triggerResource, "log_group.0.batch_size", "100"),
testAccCheckCreatedAtAttr(triggerResource),
testTriggerLogGroupEqFunctionGroup(logSrcFn, trigger),
),
},
functionTriggerImportTestStep(),
},
})
}

func testTriggerLogGroupEqFunctionGroup(fn *functions.Function, trigger *triggers.Trigger) resource.TestCheckFunc {
return func(*terraform.State) error {
lgs := trigger.Rule.GetCloudLogs().LogGroupId
if len(lgs) != 1 {
return fmt.Errorf("trigger expected to have one log group, found: %v", lgs)
}
if triggerLG := lgs[0]; triggerLG != fn.LogGroupId {
return fmt.Errorf("trigger expected to have function's log group: %s, but got: %s", fn.LogGroupId, triggerLG)
}
return nil
}
}

func TestAccYandexFunctionTrigger_logging(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -686,58 +644,6 @@ resource "yandex_storage_bucket" "tf-test" {
`, name, name, bucket, getExampleFolderID(), bucket)
}

func testYandexFunctionTriggerLogGroup(name string, batchCutoffSeconds, batchSize int) string {
return fmt.Sprintf(`
resource "yandex_iam_service_account" "test-account" {
name = "%s-acc"
}
resource "yandex_resourcemanager_folder_iam_member" "test_account" {
folder_id = "%s"
member = "serviceAccount:${yandex_iam_service_account.test-account.id}"
role = "editor"
sleep_after = 30
}
resource "yandex_function" "tf-test" {
name = "%s-func"
user_hash = "user_hash"
runtime = "python37"
entrypoint = "main"
memory = "128"
content {
zip_filename = "test-fixtures/serverless/main.zip"
}
service_account_id = yandex_iam_service_account.test-account.id
depends_on = [yandex_resourcemanager_folder_iam_member.test_account]
}
resource "yandex_function" "log-src-fn" {
name = "%s-log-src-func"
user_hash = "user_hash"
runtime = "python37"
entrypoint = "main"
memory = "128"
content {
zip_filename = "test-fixtures/serverless/main.zip"
}
}
resource "yandex_function_trigger" "test-trigger" {
name = "%s"
log_group {
log_group_ids = [yandex_function.log-src-fn.loggroup_id]
batch_cutoff = "%d"
batch_size = "%d"
}
function {
id = yandex_function.tf-test.id
service_account_id = yandex_iam_service_account.test-account.id
}
}
`, name, getExampleFolderID(), name, name, name, batchCutoffSeconds, batchSize)
}

func testYandexFunctionTriggerLogging(name string, batchCutoffSeconds, batchSize int) string {
return fmt.Sprintf(`
resource "yandex_iam_service_account" "test-account" {
Expand Down

0 comments on commit 51b2bbc

Please sign in to comment.