@@ -2,7 +2,6 @@ package amp
2
2
3
3
import (
4
4
"context"
5
- "fmt"
6
5
"log"
7
6
8
7
"github.com/aws/aws-sdk-go/aws"
@@ -16,10 +15,11 @@ import (
16
15
17
16
func ResourceRuleGroupNamespace () * schema.Resource {
18
17
return & schema.Resource {
19
- CreateContext : resourceRuleGroupNamespaceCreate ,
20
- ReadContext : resourceRuleGroupNamespaceRead ,
21
- UpdateContext : resourceRuleGroupNamespaceUpdate ,
22
- DeleteContext : resourceRuleGroupNamespaceDelete ,
18
+ CreateWithoutTimeout : resourceRuleGroupNamespaceCreate ,
19
+ ReadWithoutTimeout : resourceRuleGroupNamespaceRead ,
20
+ UpdateWithoutTimeout : resourceRuleGroupNamespaceUpdate ,
21
+ DeleteWithoutTimeout : resourceRuleGroupNamespaceDelete ,
22
+
23
23
Importer : & schema.ResourceImporter {
24
24
State : schema .ImportStatePassthrough ,
25
25
},
@@ -49,45 +49,21 @@ func resourceRuleGroupNamespaceCreate(ctx context.Context, d *schema.ResourceDat
49
49
workspaceID := d .Get ("workspace_id" ).(string )
50
50
name := d .Get ("name" ).(string )
51
51
input := & prometheusservice.CreateRuleGroupsNamespaceInput {
52
- Name : aws .String (name ),
53
52
Data : []byte (d .Get ("data" ).(string )),
53
+ Name : aws .String (name ),
54
54
WorkspaceId : aws .String (workspaceID ),
55
55
}
56
56
57
- log .Printf ("[DEBUG] Creating Prometheus Rule Group Namespace: %s" , input )
58
57
output , err := conn .CreateRuleGroupsNamespaceWithContext (ctx , input )
59
58
60
59
if err != nil {
61
- return diag .FromErr ( fmt . Errorf ("error creating Prometheus Rule Group Namespace (%s) for workspace (%s): %w " , name , workspaceID , err ) )
60
+ return diag .Errorf ("creating Prometheus Rule Group Namespace (%s) for Workspace (%s): %s " , name , workspaceID , err )
62
61
}
63
62
64
63
d .SetId (aws .StringValue (output .Arn ))
65
64
66
65
if _ , err := waitRuleGroupNamespaceCreated (ctx , conn , d .Id ()); err != nil {
67
- return diag .FromErr (fmt .Errorf ("error waiting for Prometheus Rule Group Namespace (%s) create: %w" , d .Id (), err ))
68
- }
69
-
70
- return resourceRuleGroupNamespaceRead (ctx , d , meta )
71
- }
72
-
73
- func resourceRuleGroupNamespaceUpdate (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
74
- conn := meta .(* conns.AWSClient ).AMPConn
75
-
76
- input := & prometheusservice.PutRuleGroupsNamespaceInput {
77
- Name : aws .String (d .Get ("name" ).(string )),
78
- Data : []byte (d .Get ("data" ).(string )),
79
- WorkspaceId : aws .String (d .Get ("workspace_id" ).(string )),
80
- }
81
-
82
- log .Printf ("[DEBUG] Updating Prometheus Rule Group Namespace: %s" , input )
83
- _ , err := conn .PutRuleGroupsNamespaceWithContext (ctx , input )
84
-
85
- if err != nil {
86
- return diag .FromErr (fmt .Errorf ("error updating Prometheus Rule Group Namespace (%s): %w" , d .Id (), err ))
87
- }
88
-
89
- if _ , err := waitRuleGroupNamespaceUpdated (ctx , conn , d .Id ()); err != nil {
90
- return diag .FromErr (fmt .Errorf ("error waiting for Prometheus Rule Group Namespace (%s) update: %w" , d .Id (), err ))
66
+ return diag .Errorf ("waiting for Prometheus Rule Group Namespace (%s) create: %s" , d .Id (), err )
91
67
}
92
68
93
69
return resourceRuleGroupNamespaceRead (ctx , d , meta )
@@ -105,7 +81,7 @@ func resourceRuleGroupNamespaceRead(ctx context.Context, d *schema.ResourceData,
105
81
}
106
82
107
83
if err != nil {
108
- return diag .FromErr ( fmt . Errorf ("error reading Prometheus Rule Group Namespace (%s): %w " , d .Id (), err ) )
84
+ return diag .Errorf ("reading Prometheus Rule Group Namespace (%s): %s " , d .Id (), err )
109
85
}
110
86
111
87
d .Set ("data" , string (rgn .Data ))
@@ -119,6 +95,28 @@ func resourceRuleGroupNamespaceRead(ctx context.Context, d *schema.ResourceData,
119
95
return nil
120
96
}
121
97
98
+ func resourceRuleGroupNamespaceUpdate (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
99
+ conn := meta .(* conns.AWSClient ).AMPConn
100
+
101
+ input := & prometheusservice.PutRuleGroupsNamespaceInput {
102
+ Data : []byte (d .Get ("data" ).(string )),
103
+ Name : aws .String (d .Get ("name" ).(string )),
104
+ WorkspaceId : aws .String (d .Get ("workspace_id" ).(string )),
105
+ }
106
+
107
+ _ , err := conn .PutRuleGroupsNamespaceWithContext (ctx , input )
108
+
109
+ if err != nil {
110
+ return diag .Errorf ("updating Prometheus Rule Group Namespace (%s): %s" , d .Id (), err )
111
+ }
112
+
113
+ if _ , err := waitRuleGroupNamespaceUpdated (ctx , conn , d .Id ()); err != nil {
114
+ return diag .Errorf ("waiting for Prometheus Rule Group Namespace (%s) update: %s" , d .Id (), err )
115
+ }
116
+
117
+ return resourceRuleGroupNamespaceRead (ctx , d , meta )
118
+ }
119
+
122
120
func resourceRuleGroupNamespaceDelete (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
123
121
conn := meta .(* conns.AWSClient ).AMPConn
124
122
@@ -133,11 +131,11 @@ func resourceRuleGroupNamespaceDelete(ctx context.Context, d *schema.ResourceDat
133
131
}
134
132
135
133
if err != nil {
136
- return diag .FromErr ( fmt . Errorf ("error deleting Prometheus Rule Group Namespace (%s): %w " , d .Id (), err ) )
134
+ return diag .Errorf ("deleting Prometheus Rule Group Namespace (%s): %s " , d .Id (), err )
137
135
}
138
136
139
137
if _ , err := waitRuleGroupNamespaceDeleted (ctx , conn , d .Id ()); err != nil {
140
- return diag .FromErr ( fmt . Errorf ("error waiting for Prometheus Rule Group Namespace (%s) delete: %w " , d .Id (), err ) )
138
+ return diag .Errorf ("waiting for Prometheus Rule Group Namespace (%s) delete: %s " , d .Id (), err )
141
139
}
142
140
143
141
return nil
0 commit comments