-
Notifications
You must be signed in to change notification settings - Fork 112
/
config.go
48 lines (42 loc) · 1.91 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// SPDX-FileCopyrightText: 2024 The Crossplane Authors <https://crossplane.io>
//
// SPDX-License-Identifier: CC0-1.0
package cloudwatchlogs
import (
"github.com/crossplane/upjet/pkg/config"
"github.com/upbound/provider-aws/config/common"
)
// Configure adds configurations for the cloudwatchlogs group.
func Configure(p *config.Provider) {
p.AddResourceConfigurator("aws_cloudwatch_log_destination", func(r *config.Resource) {
// the target_arn field is generated together with the associated
// referencer fields but the auto-generated extractor refers to
// the `spec` of the target kinesis.Stream, whereas the ARN resides
// in the `status`. This is caused by the fact that kinesis.Stream has
// resource configuration that moves the `arn` field from `spec` to
// `status` but this resource configuration is currently not available to
// reference injector (because reference injections happens at an earlier
// stage). For now, we are just replacing the auto-injected reference
// with a manual reference with the correct extractor. But if
// we observe more cases of this, we may reconsider making reference
// injection be able to consume the last state of resource configuration.
r.References["target_arn"] = config.Reference{
TerraformName: "aws_kinesis_stream",
Extractor: common.PathTerraformIDExtractor,
}
})
p.AddResourceConfigurator("aws_cloudwatch_log_subscription_filter", func(r *config.Resource) {
// Please see the comment for aws_cloudwatch_log_destination.target_arn
// reference configuration
r.References["destination_arn"] = config.Reference{
TerraformName: "aws_kinesis_stream",
Extractor: common.PathTerraformIDExtractor,
}
})
p.AddResourceConfigurator("aws_cloudwatch_log_group", func(r *config.Resource) {
config.MarkAsRequired(r.TerraformResource, "name")
r.LateInitializer = config.LateInitializer{
IgnoredFields: []string{"name_prefix"},
}
})
}