Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add call_as support for stackset #22440

Merged
merged 5 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/22440.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_cloudformation_stack_set: Add `call_as` argument
```
14 changes: 14 additions & 0 deletions internal/service/cloudformation/stack_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ func ResourceStackSet() *schema.Resource {
},
},
},
"call_as": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice(cloudformation.CallAs_Values(), false),
Default: cloudformation.CallAsSelf,
},
"capabilities": {
Type: schema.TypeSet,
Optional: true,
Expand Down Expand Up @@ -171,6 +177,10 @@ func resourceStackSetCreate(d *schema.ResourceData, meta interface{}) error {
input.PermissionModel = aws.String(v.(string))
}

if v, ok := d.GetOk("call_as"); ok {
input.CallAs = aws.String(v.(string))
}

if len(tags) > 0 {
input.Tags = Tags(tags.IgnoreAWS())
}
Expand Down Expand Up @@ -286,6 +296,10 @@ func resourceStackSetUpdate(d *schema.ResourceData, meta interface{}) error {
input.PermissionModel = aws.String(v.(string))
}

if v, ok := d.GetOk("call_as"); ok {
input.CallAs = aws.String(v.(string))
}

if len(tags) > 0 {
input.Tags = Tags(tags.IgnoreAWS())
}
Expand Down
13 changes: 13 additions & 0 deletions internal/service/cloudformation/stack_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func TestAccCloudFormationStackSet_basic(t *testing.T) {
resource.TestCheckResourceAttrPair(resourceName, "administration_role_arn", iamRoleResourceName, "arn"),
acctest.MatchResourceAttrRegionalARN(resourceName, "arn", "cloudformation", regexp.MustCompile(`stackset/.+`)),
resource.TestCheckResourceAttr(resourceName, "capabilities.#", "0"),
resource.TestCheckResourceAttr(resourceName, "call_as", "SELF"),
resource.TestCheckResourceAttr(resourceName, "description", ""),
resource.TestCheckResourceAttr(resourceName, "execution_role_name", "AWSCloudFormationStackSetExecutionRole"),
resource.TestCheckResourceAttr(resourceName, "name", rName),
Expand All @@ -52,6 +53,7 @@ func TestAccCloudFormationStackSet_basic(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"call_as",
ewbankkit marked this conversation as resolved.
Show resolved Hide resolved
"template_url",
},
},
Expand Down Expand Up @@ -107,6 +109,7 @@ func TestAccCloudFormationStackSet_administrationRoleARN(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"call_as",
"template_url",
},
},
Expand Down Expand Up @@ -145,6 +148,7 @@ func TestAccCloudFormationStackSet_description(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"call_as",
"template_url",
},
},
Expand Down Expand Up @@ -183,6 +187,7 @@ func TestAccCloudFormationStackSet_executionRoleName(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"call_as",
"template_url",
},
},
Expand Down Expand Up @@ -238,6 +243,7 @@ func TestAccCloudFormationStackSet_name(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"call_as",
"template_url",
},
},
Expand Down Expand Up @@ -277,6 +283,7 @@ func TestAccCloudFormationStackSet_parameters(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"call_as",
"template_url",
},
},
Expand Down Expand Up @@ -337,6 +344,7 @@ func TestAccCloudFormationStackSet_Parameters_default(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"call_as",
"template_url",
},
},
Expand Down Expand Up @@ -389,6 +397,7 @@ func TestAccCloudFormationStackSet_Parameters_noEcho(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"call_as",
"template_url",
},
},
Expand Down Expand Up @@ -439,6 +448,7 @@ func TestAccCloudFormationStackSet_PermissionModel_serviceManaged(t *testing.T)
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"call_as",
"template_url",
},
},
Expand Down Expand Up @@ -470,6 +480,7 @@ func TestAccCloudFormationStackSet_tags(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"call_as",
"template_url",
},
},
Expand Down Expand Up @@ -525,6 +536,7 @@ func TestAccCloudFormationStackSet_templateBody(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"call_as",
"template_url",
},
},
Expand Down Expand Up @@ -564,6 +576,7 @@ func TestAccCloudFormationStackSet_templateURL(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"call_as",
"template_url",
},
},
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/cloudformation_stack_set.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ The following arguments are supported:
* `execution_role_name` - (Optional) Name of the IAM Role in all target accounts for StackSet operations. Defaults to `AWSCloudFormationStackSetExecutionRole` when using the `SELF_MANAGED` permission model. This should not be defined when using the `SERVICE_MANAGED` permission model.
* `parameters` - (Optional) Key-value map of input parameters for the StackSet template. All template parameters, including those with a `Default`, must be configured or ignored with `lifecycle` configuration block `ignore_changes` argument. All `NoEcho` template parameters must be ignored with the `lifecycle` configuration block `ignore_changes` argument.
* `permission_model` - (Optional) Describes how the IAM roles required for your StackSet are created. Valid values: `SELF_MANAGED` (default), `SERVICE_MANAGED`.
* `call_as` - (Optional) Specifies whether you are acting as an account administrator in the organization's management account or as a delegated administrator in a member account. Valid values: `SELF` (default), `DELEGATED_ADMIN`.
* `tags` - (Optional) Key-value map of tags to associate with this StackSet and the Stacks created from it. AWS CloudFormation also propagates these tags to supported resources that are created in the Stacks. A maximum number of 50 tags can be specified. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.
* `template_body` - (Optional) String containing the CloudFormation template body. Maximum size: 51,200 bytes. Conflicts with `template_url`.
* `template_url` - (Optional) String containing the location of a file containing the CloudFormation template body. The URL must point to a template that is located in an Amazon S3 bucket. Maximum location file size: 460,800 bytes. Conflicts with `template_body`.
Expand Down