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 new 'mssql_role' resource to manipulate role of a SQL Server. #51

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

paulbrittain
Copy link

Hello, I hope this PR finds you well.

The objective of this PR is primarily to add a new resource mssql_role for manipulating SQL Server Roles.

Other changes include

  • Bumping dependency versions for the examples
  • kreuzwerker is now the source for the docker provider https://registry.terraform.io/providers/kreuzwerker/docker/latest/docs
  • Added the ability to debug the provider by passing a -debug flag parameter.
  • Removed some unused code, such as in the function testAccImportStateId, now renamed to testResourceTryGetStateId
  • Tests added
  • Documentation added, changelog updated, and version bumped.

Note: I've tried to run the acceptance tests against Azure AD with no success. Further attempts are ongoing but the issue is likely related to Azure Firewall rules. Acceptance tests pass locally. I can provide an update here if progress is made.

image

If none is possible, can the acceptance tests be ran + verified by an existing pipeline or by a maintainer?

PS. The changelog needs to be updated with the diff link for the proposed minor verson bump when it's available.

Many thanks

@paulbrittain paulbrittain changed the title Add mssql_role to manipulate role of a SQL Server. Add new 'mssql_role' resource to manipulate role of a SQL Server. Dec 14, 2022
The following arguments are supported:

* `server` - (Required) Server and login details for the SQL Server. The attributes supported in the `server` block is detailed below.
* `role_name` - (Required) The name of the roler. Changing this resource property modifies the existing resource.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* `role_name` - (Required) The name of the roler. Changing this resource property modifies the existing resource.
* `role_name` - (Required) The name of the role. Changing this resource property modifies the existing resource.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

docs/resources/role.md Outdated Show resolved Hide resolved

func (c *Connector) CreateRole(ctx context.Context, database, roleName string) error {
cmd := `DECLARE @sql nvarchar(max);
SET @sql = 'CREATE ROLE ' + QuoteName(@roleName);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think one potential improvement here could be to also support authorization. But that can probably be added in another PR:
CREATE ROLE role_name [ AUTHORIZATION owner_name ]

@@ -24,3 +24,12 @@ variable "local_ip_addresses" {
description = "The external IP addresses of the machines running the acceptance tests. This is necessary to allow access to the Azure SQL Server resource."
type = list(string)
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is odd, you need this variable only to run the local tests, where the sql server is started in the Docker container. Is there no better fix for this?

@BasLangenberg
Copy link

Hi - Is there any chance this will be merged and pushed to the TF registry? We are having a need for this functionality at work as well. :-)

Thanks!

Copy link
Contributor

@magne magne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • All the import acceptance tests (TestAccLogin_Local_BasicImport, Test_resourceRoleImport, and TestAccUser_Local_Import) fail.
  • The PR should be merged with master to bring it up to date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants