-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
New Resource: r/aws_fms_admin_account #4310
Conversation
Seems like the call to |
9a07724
to
cb74563
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @gazoakley! Left some initial comments below. Please take a look and let us know if you have any questions.
Schema: map[string]*schema.Schema{ | ||
"account_id": { | ||
Type: schema.TypeString, | ||
Required: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we instead make this Optional: true
and use meta.(*AWSClient).accountid
if its not provided? e.g.
if v, ok := d.GetOk("account_id"); ok && v != "" {
accountID := v.(string)
} else {
accountID := meta.(*AWSClient).accountid
}
return fmt.Errorf("Error waiting for firewall manager admin account association (%s): %s", accountId, sterr) | ||
} | ||
|
||
d.SetId("fms-admin-account") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we don't necessarily need to reference it during read/delete at the moment, can you set this to accountId
still? It'll make the ID available if we need it in the future and the import a little more obvious:
# Currently:
terraform import aws_fms_admin_account.example fms-admin-account
# Proposed:
terraform import aws_fms_admin_account.example 123456789012
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bflad I adopted this approach from aws_iam_account_password_policy
(aws_spot_datafeed_subscription
does this too) since only one FMS admin account can be associated to an account. My concern is that the user can disassociate/associate a different admin account outside Terraform - it might be confusing/misleading to have the resource ID as an account ID different to associated admin account ID. I'm guessing it wouldn't be safe to call SetId
during a read operation if the associated admin account has changed? Any suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can check d.Id() != aws.StringValue(res.AdminAccount)
to trigger recreation:
if d.Id() != aws.StringValue(res.AdminAccount) {
log.Printf("[WARN] FMS Admin Account does not match, removing from state", d.Id())
d.SetId("")
return nil
}
Read: resourceAwsFmsAdminAccountRead, | ||
Delete: resourceAwsFmsAdminAccountDelete, | ||
|
||
Importer: &schema.ResourceImporter{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing ## Import
documentation section
// but does not define this in its error codes | ||
if isAWSErr(err, "AccessDeniedException", "is not currently delegated by AWS FM") { | ||
log.Printf("[WARN] No associated firewall manager admin account found, removing from state: %s", d.Id()) | ||
d.SetId("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We no longer need d.SetId("")
during deletion functions. See also #4191
return fmt.Errorf("Error disassociating firewall manager admin account: %s", err) | ||
} | ||
|
||
d.SetId("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We no longer need d.SetId("")
during deletion functions. See also #4191
conn := testAccProvider.Meta().(*AWSClient).fmsconn | ||
|
||
for _, rs := range s.RootModule().Resources { | ||
if rs.Type != "aws_config_authorization" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copy paste typo 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops! 🤣
cb74563
to
68d9d7d
Compare
Any update for resolving conflicts and getting Firewall Manager merged? |
Hi @gazoakley is there any appetite to finish this PR? Cheers. |
Hi folks 👋 Apologies for the delays here. We went ahead and rebased this pull request, tidied it up, and merged it in. Thanks @gazoakley for the contribution. 🚀 |
This has been released in version 2.22.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Closes #4057
New Resources:
aws_fms_admin_account