9
9
"testing"
10
10
11
11
awstypes "github.com/aws/aws-sdk-go-v2/service/lambda/types"
12
+ sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
12
13
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
13
14
"github.com/hashicorp/terraform-plugin-testing/terraform"
14
15
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
@@ -26,7 +27,10 @@ func TestAccLambdaCodeSigningConfig_basic(t *testing.T) {
26
27
var conf awstypes.CodeSigningConfig
27
28
28
29
resource .ParallelTest (t , resource.TestCase {
29
- PreCheck : func () { acctest .PreCheck (ctx , t ) },
30
+ PreCheck : func () {
31
+ acctest .PreCheck (ctx , t )
32
+ acctest .PreCheckPartitionNot (t , names .USGovCloudPartitionID )
33
+ },
30
34
ErrorCheck : acctest .ErrorCheck (t , names .LambdaServiceID ),
31
35
ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
32
36
CheckDestroy : testAccCheckCodeSigningConfigDestroy (ctx ),
@@ -57,7 +61,10 @@ func TestAccLambdaCodeSigningConfig_disappears(t *testing.T) {
57
61
var conf awstypes.CodeSigningConfig
58
62
59
63
resource .ParallelTest (t , resource.TestCase {
60
- PreCheck : func () { acctest .PreCheck (ctx , t ) },
64
+ PreCheck : func () {
65
+ acctest .PreCheck (ctx , t )
66
+ acctest .PreCheckPartitionNot (t , names .USGovCloudPartitionID )
67
+ },
61
68
ErrorCheck : acctest .ErrorCheck (t , names .LambdaServiceID ),
62
69
ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
63
70
CheckDestroy : testAccCheckCodeSigningConfigDestroy (ctx ),
@@ -74,13 +81,65 @@ func TestAccLambdaCodeSigningConfig_disappears(t *testing.T) {
74
81
})
75
82
}
76
83
84
+ func TestAccLambdaCodeSigningConfig_tags (t * testing.T ) {
85
+ ctx := acctest .Context (t )
86
+ resourceName := "aws_lambda_code_signing_config.code_signing_config"
87
+ rName := sdkacctest .RandomWithPrefix (acctest .ResourcePrefix )
88
+ var conf awstypes.CodeSigningConfig
89
+
90
+ resource .ParallelTest (t , resource.TestCase {
91
+ PreCheck : func () {
92
+ acctest .PreCheck (ctx , t )
93
+ acctest .PreCheckPartitionNot (t , names .USGovCloudPartitionID )
94
+ },
95
+ ErrorCheck : acctest .ErrorCheck (t , names .LambdaServiceID ),
96
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
97
+ CheckDestroy : testAccCheckCodeSigningConfigDestroy (ctx ),
98
+ Steps : []resource.TestStep {
99
+ {
100
+ Config : testAccCodeSigningConfigConfig_tags1 (rName , acctest .CtKey1 , acctest .CtValue1 ),
101
+ Check : resource .ComposeTestCheckFunc (
102
+ testAccCheckCodeSigningConfigExists (ctx , resourceName , & conf ),
103
+ resource .TestCheckResourceAttr (resourceName , acctest .CtTagsPercent , acctest .Ct1 ),
104
+ resource .TestCheckResourceAttr (resourceName , acctest .CtTagsKey1 , acctest .CtValue1 ),
105
+ ),
106
+ },
107
+ {
108
+ ResourceName : resourceName ,
109
+ ImportState : true ,
110
+ ImportStateVerify : true ,
111
+ },
112
+ {
113
+ Config : testAccCodeSigningConfigConfig_tags2 (rName , acctest .CtKey1 , acctest .CtValue1Updated , acctest .CtKey2 , acctest .CtValue2 ),
114
+ Check : resource .ComposeTestCheckFunc (
115
+ testAccCheckCodeSigningConfigExists (ctx , resourceName , & conf ),
116
+ resource .TestCheckResourceAttr (resourceName , acctest .CtTagsPercent , acctest .Ct2 ),
117
+ resource .TestCheckResourceAttr (resourceName , acctest .CtTagsKey1 , acctest .CtValue1Updated ),
118
+ resource .TestCheckResourceAttr (resourceName , acctest .CtTagsKey2 , acctest .CtValue2 ),
119
+ ),
120
+ },
121
+ {
122
+ Config : testAccCodeSigningConfigConfig_tags1 (rName , acctest .CtKey2 , acctest .CtValue2 ),
123
+ Check : resource .ComposeTestCheckFunc (
124
+ testAccCheckCodeSigningConfigExists (ctx , resourceName , & conf ),
125
+ resource .TestCheckResourceAttr (resourceName , acctest .CtTagsPercent , acctest .Ct1 ),
126
+ resource .TestCheckResourceAttr (resourceName , acctest .CtTagsKey2 , acctest .CtValue2 ),
127
+ ),
128
+ },
129
+ },
130
+ })
131
+ }
132
+
77
133
func TestAccLambdaCodeSigningConfig_updatePolicy (t * testing.T ) {
78
134
ctx := acctest .Context (t )
79
135
resourceName := "aws_lambda_code_signing_config.code_signing_config"
80
136
var conf awstypes.CodeSigningConfig
81
137
82
138
resource .ParallelTest (t , resource.TestCase {
83
- PreCheck : func () { acctest .PreCheck (ctx , t ) },
139
+ PreCheck : func () {
140
+ acctest .PreCheck (ctx , t )
141
+ acctest .PreCheckPartitionNot (t , names .USGovCloudPartitionID )
142
+ },
84
143
ErrorCheck : acctest .ErrorCheck (t , names .LambdaServiceID ),
85
144
ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
86
145
CheckDestroy : testAccCheckCodeSigningConfigDestroy (ctx ),
@@ -117,7 +176,10 @@ func TestAccLambdaCodeSigningConfig_updatePublishers(t *testing.T) {
117
176
var conf awstypes.CodeSigningConfig
118
177
119
178
resource .ParallelTest (t , resource.TestCase {
120
- PreCheck : func () { acctest .PreCheck (ctx , t ) },
179
+ PreCheck : func () {
180
+ acctest .PreCheck (ctx , t )
181
+ acctest .PreCheckPartitionNot (t , names .USGovCloudPartitionID )
182
+ },
121
183
ErrorCheck : acctest .ErrorCheck (t , names .LambdaServiceID ),
122
184
ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories ,
123
185
CheckDestroy : testAccCheckCodeSigningConfigDestroy (ctx ),
@@ -222,6 +284,47 @@ resource "aws_lambda_code_signing_config" "code_signing_config" {
222
284
}`
223
285
}
224
286
287
+ func testAccCodeSigningConfigConfig_tags1 (rName , tagKey1 , tagValue1 string ) string {
288
+ return fmt .Sprintf (`
289
+ resource "aws_signer_signing_profile" "test" {
290
+ platform_id = "AWSLambda-SHA384-ECDSA"
291
+ }
292
+
293
+ resource "aws_lambda_code_signing_config" "code_signing_config" {
294
+ allowed_publishers {
295
+ signing_profile_version_arns = [
296
+ aws_signer_signing_profile.test.version_arn,
297
+ ]
298
+ }
299
+
300
+ tags = {
301
+ %[2]q = %[3]q
302
+ }
303
+ }
304
+ ` , rName , tagKey1 , tagValue1 )
305
+ }
306
+
307
+ func testAccCodeSigningConfigConfig_tags2 (rName , tagKey1 , tagValue1 , tagKey2 , tagValue2 string ) string {
308
+ return fmt .Sprintf (`
309
+ resource "aws_signer_signing_profile" "test" {
310
+ platform_id = "AWSLambda-SHA384-ECDSA"
311
+ }
312
+
313
+ resource "aws_lambda_code_signing_config" "code_signing_config" {
314
+ allowed_publishers {
315
+ signing_profile_version_arns = [
316
+ aws_signer_signing_profile.test.version_arn,
317
+ ]
318
+ }
319
+
320
+ tags = {
321
+ %[2]q = %[3]q
322
+ %[4]q = %[5]q
323
+ }
324
+ }
325
+ ` , rName , tagKey1 , tagValue1 , tagKey2 , tagValue2 )
326
+ }
327
+
225
328
func testAccCodeSigningConfigConfig_updatePublishers () string {
226
329
return `
227
330
resource "aws_signer_signing_profile" "test1" {
0 commit comments