Skip to content

Commit 1b8dc75

Browse files
alexng-canuckrcohenma
authored andcommitted
Add support for cost tracking in tags
1 parent 01088fa commit 1b8dc75

14 files changed

+40
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Support for encrypting the contents of an Object Storage bucket using a Key Management Service key
1111
- Support for specifying a Key Management Service key when launching a compute instance in the Compute service
1212
- Support for specifying a Key Management Service key when backing up or restoring a block storage volume in the Block Volume service
13+
- Support for cost tracking in tags
1314

1415
### Fixed
1516
- Data type for properties with type as TypeSet to TypeList in following datasources: `oci_core_route_tables`, `oci_core_security_lists`, `oci_core_volume`, and `oci_core_service_gateways` to allow referencing by indexes in Terraform configs.

oci/identity_tag_resource.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ func TagResource() *schema.Resource {
5353
Computed: true,
5454
Elem: schema.TypeString,
5555
},
56+
"is_cost_tracking": {
57+
Type: schema.TypeBool,
58+
Optional: true,
59+
Computed: true,
60+
},
5661
"is_retired": {
5762
Type: schema.TypeBool,
5863
Optional: true,
@@ -127,6 +132,11 @@ func (s *TagResourceCrud) Create() error {
127132
request.FreeformTags = objectMapToStringMap(freeformTags.(map[string]interface{}))
128133
}
129134

135+
if isCostTracking, ok := s.D.GetOkExists("is_cost_tracking"); ok {
136+
tmp := isCostTracking.(bool)
137+
request.IsCostTracking = &tmp
138+
}
139+
130140
if name, ok := s.D.GetOkExists("name"); ok {
131141
tmp := name.(string)
132142
request.Name = &tmp
@@ -228,6 +238,11 @@ func (s *TagResourceCrud) Update() error {
228238
request.FreeformTags = objectMapToStringMap(freeformTags.(map[string]interface{}))
229239
}
230240

241+
if isCostTracking, ok := s.D.GetOkExists("is_cost_tracking"); ok {
242+
tmp := isCostTracking.(bool)
243+
request.IsCostTracking = &tmp
244+
}
245+
231246
if isRetired, ok := s.D.GetOkExists("is_retired"); ok {
232247
tmp := isRetired.(bool)
233248
request.IsRetired = &tmp
@@ -265,6 +280,10 @@ func (s *TagResourceCrud) SetData() error {
265280

266281
s.D.Set("freeform_tags", s.Res.FreeformTags)
267282

283+
if s.Res.IsCostTracking != nil {
284+
s.D.Set("is_cost_tracking", *s.Res.IsCostTracking)
285+
}
286+
268287
if s.Res.IsRetired != nil {
269288
s.D.Set("is_retired", *s.Res.IsRetired)
270289
}

oci/identity_tag_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ var (
5151
"tag_namespace_id": Representation{repType: Required, create: `${oci_identity_tag_namespace.test_tag_namespace.id}`},
5252
"defined_tags": Representation{repType: Optional, create: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "value")}`, update: `${map("${oci_identity_tag_namespace.tag-namespace1.name}.${oci_identity_tag.tag1.name}", "updatedValue")}`},
5353
"freeform_tags": Representation{repType: Optional, create: map[string]string{"Department": "Finance"}, update: map[string]string{"Department": "Accounting"}},
54+
"is_cost_tracking": Representation{repType: Optional, create: `false`, update: `true`},
5455
}
5556

5657
TagResourceDependencies = TagNamespaceRequiredOnlyResource
@@ -103,6 +104,7 @@ func TestIdentityTagResource_basic(t *testing.T) {
103104
resource.TestCheckResourceAttr(resourceName, "description", "This tag will show the cost center that will be used for billing of associated resources."),
104105
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
105106
resource.TestCheckResourceAttrSet(resourceName, "id"),
107+
resource.TestCheckResourceAttr(resourceName, "is_cost_tracking", "false"),
106108
resource.TestCheckResourceAttrSet(resourceName, "is_retired"),
107109
resource.TestCheckResourceAttr(resourceName, "name", "CostCenter"),
108110
resource.TestCheckResourceAttrSet(resourceName, "tag_namespace_id"),
@@ -124,6 +126,7 @@ func TestIdentityTagResource_basic(t *testing.T) {
124126
resource.TestCheckResourceAttr(resourceName, "description", "description2"),
125127
resource.TestCheckResourceAttr(resourceName, "freeform_tags.%", "1"),
126128
resource.TestCheckResourceAttrSet(resourceName, "id"),
129+
resource.TestCheckResourceAttr(resourceName, "is_cost_tracking", "true"),
127130
resource.TestCheckResourceAttrSet(resourceName, "is_retired"),
128131
resource.TestCheckResourceAttr(resourceName, "name", "CostCenter"),
129132
resource.TestCheckResourceAttrSet(resourceName, "tag_namespace_id"),
@@ -152,6 +155,7 @@ func TestIdentityTagResource_basic(t *testing.T) {
152155
resource.TestCheckResourceAttr(datasourceName, "tags.0.description", "description2"),
153156
resource.TestCheckResourceAttr(datasourceName, "tags.0.freeform_tags.%", "1"),
154157
resource.TestCheckResourceAttrSet(datasourceName, "tags.0.id"),
158+
resource.TestCheckResourceAttr(datasourceName, "tags.0.is_cost_tracking", "true"),
155159
resource.TestCheckResourceAttrSet(datasourceName, "tags.0.is_retired"),
156160
resource.TestCheckResourceAttr(datasourceName, "tags.0.name", "CostCenter"),
157161
resource.TestCheckResourceAttrSet(datasourceName, "tags.0.time_created"),

oci/identity_tags_data_source.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ func (s *TagsDataSourceCrud) SetData() error {
101101
tag["id"] = *r.Id
102102
}
103103

104+
if r.IsCostTracking != nil {
105+
tag["is_cost_tracking"] = *r.IsCostTracking
106+
}
107+
104108
if r.IsRetired != nil {
105109
tag["is_retired"] = *r.IsRetired
106110
}

website/docs/d/identity_dynamic_groups.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ data "oci_identity_dynamic_groups" "test_dynamic_groups" {
2727

2828
The following arguments are supported:
2929

30-
* `compartment_id` - (Required) The OCID of the compartment (remember that the tenancy is simply the root compartment).
30+
* `compartment_id` - (Required) The OCID of the parent compartment (remember that the tenancy is simply the root compartment).
3131

3232

3333
## Attributes Reference

website/docs/d/identity_fault_domains.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ data "oci_identity_fault_domains" "test_fault_domains" {
2929
The following arguments are supported:
3030

3131
* `availability_domain` - (Required) The name of the availibilityDomain.
32-
* `compartment_id` - (Required) The OCID of the compartment (remember that the tenancy is simply the root compartment).
32+
* `compartment_id` - (Required) The OCID of the parent compartment (remember that the tenancy is simply the root compartment).
3333

3434

3535
## Attributes Reference

website/docs/d/identity_groups.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ data "oci_identity_groups" "test_groups" {
2727

2828
The following arguments are supported:
2929

30-
* `compartment_id` - (Required) The OCID of the compartment (remember that the tenancy is simply the root compartment).
30+
* `compartment_id` - (Required) The OCID of the parent compartment (remember that the tenancy is simply the root compartment).
3131

3232

3333
## Attributes Reference

website/docs/d/identity_identity_providers.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ data "oci_identity_identity_providers" "test_identity_providers" {
2929

3030
The following arguments are supported:
3131

32-
* `compartment_id` - (Required) The OCID of the compartment (remember that the tenancy is simply the root compartment).
32+
* `compartment_id` - (Required) The OCID of the parent compartment (remember that the tenancy is simply the root compartment).
3333
* `protocol` - (Required) The protocol used for federation.
3434

3535

website/docs/d/identity_policies.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ data "oci_identity_policies" "test_policies" {
2929

3030
The following arguments are supported:
3131

32-
* `compartment_id` - (Required) The OCID of the compartment (remember that the tenancy is simply the root compartment).
32+
* `compartment_id` - (Required) The OCID of the parent compartment (remember that the tenancy is simply the root compartment).
3333

3434

3535
## Attributes Reference

website/docs/d/identity_tag_namespaces.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ data "oci_identity_tag_namespaces" "test_tag_namespaces" {
2828

2929
The following arguments are supported:
3030

31-
* `compartment_id` - (Required) The OCID of the compartment (remember that the tenancy is simply the root compartment).
31+
* `compartment_id` - (Required) The OCID of the parent compartment (remember that the tenancy is simply the root compartment).
3232
* `include_subcompartments` - (Optional) An optional boolean parameter indicating whether to retrieve all tag namespaces in subcompartments. If this parameter is not specified, only the tag namespaces defined in the specified compartment are retrieved.
3333

3434

0 commit comments

Comments
 (0)