-
Notifications
You must be signed in to change notification settings - Fork 523
/
cloudfront_distribution.go
37 lines (33 loc) 路 1.3 KB
/
cloudfront_distribution.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
package aws
import (
"github.com/infracost/infracost/internal/resources/aws"
"github.com/infracost/infracost/internal/schema"
)
func getCloudfrontDistributionRegistryItem() *schema.RegistryItem {
return &schema.RegistryItem{
Name: "aws_cloudfront_distribution",
CoreRFunc: newCloudfrontDistribution,
ReferenceAttributes: []string{
"origin.0.domain_name",
"origin.0.origin_id",
},
}
}
func newCloudfrontDistribution(d *schema.ResourceData) schema.CoreResource {
region := d.Get("region").String()
isOriginShieldEnabled := d.Get("origin.0.origin_shield.0.enabled").Bool()
isSSLSupportMethodVIP := d.Get("viewer_certificate.0.ssl_support_method").String() == "vip"
hasLoggingConfigBucket := !d.IsEmpty("logging_config.0.bucket")
hasFieldLevelEncryptionID := !d.IsEmpty("default_cache_behavior.0.field_level_encryption_id")
originShieldRegion := d.Get("origin.0.origin_shield.0.origin_shield_region").String()
r := &aws.CloudfrontDistribution{
Address: d.Address,
Region: region,
IsOriginShieldEnabled: isOriginShieldEnabled,
IsSSLSupportMethodVIP: isSSLSupportMethodVIP,
HasLoggingConfigBucket: hasLoggingConfigBucket,
HasFieldLevelEncryptionID: hasFieldLevelEncryptionID,
OriginShieldRegion: originShieldRegion,
}
return r
}