Hi All :wave: I have created a _Microsoft SQL Ser...
# aws
k
Hi All 👋 I have created a _Microsoft SQL Server (SQL server express edition)_ database instance in Amazon RDS using
aws.rds.Instance
(aws classic package). Now I want to expose the Endpoint, the Port, the
DBname
, the
UserId
of a DB user, and the
Password
of that DB user as [Output] variables. Endpoint and Port are accessible easily as output properties. No problem with those. However, I have several doubts to be clarified regarding the
DBname
,
UserId
, and
Password
. 1. Here it is mentioned that the
DBName
input property is not applied to the Microsoft SQL Server. So, is there any other way to create an initial database when the Microsoft SQL Server DB instance is created? 2. Suppose I want to create a DB user with read-only permissions. Is there a way to create such a DB user using Pulumi? Or Do I need to create a DB user using SQL commands by accessing the database manually? 3. Can SQL commands be executed on the created Microsoft SQL Server database using Pulumi? Any help is highly appreciated. TIA
l
You can use the MSSQL provider to do all this: https://www.pulumi.com/registry/packages/mssql/ This is good for code-as-documentation and explicitly saying what the DB will contain.
If you're looking to set up an initial database that will always be the same, and doing it frequently enough that speed is a concern, then I recommend setting up the "template" database manually, backing it up, storing the backup in S3, and configuring RDS to build from that backup.
Restoring a single small backup is, in my experience, much faster than setting up all the DB entities individually.
k
Thank you @little-cartoon-10569 for your help. I looked into this. As mentioned here below code can create an MSSQL server in Azure. However, I couldn't able to find an equivalent code to create an MSSQL server in Azure. I wonder whether this package supports only Azure. Not for AWS 🤔
Copy code
var server = new Azure.MSSql.Server(
        "server",
        new()
        {
            Name = "pulumi-mssql-test",
            ResourceGroupName = resourceGroup.Name,
            Location = resourceGroup.Location,
            Version = "12.0",
            MinimumTlsVersion = "1.2",
            AdministratorLogin = "sadmin",
            AdministratorLoginPassword = "Str0ngPa$word12",
            AzureadAdministrator = new Azure.MSSql.Inputs.ServerAzureadAdministratorArgs
            {
                LoginUsername = "pulumi-app",
                ObjectId = current.ObjectId,
                TenantId = current.TenantId,
            },
        }
    );
Additionally, we can create an MSSQL server instance using Pulumi.Aws.Rds.Instance. But, when we try to run
pulumi up
with that approach (Creating a Server using Pulumi.Aws.Rds.Instance and creating DB users using Pulumiverse.MSSQL package), it also shows the below error.
Copy code
pulumi:providers:mssql (default_0_0_7_github_/api.github.com/pulumiverse/pulumi-mssql):
    error: rpc error: code = Unknown desc = Missing SQL authentication config: One of authentication methods must be provided: sql_auth, azure_auth
l
The Azure package is not relevant for RDS. To work with MSSQL in RDS, use the non-Azure package (mssql.Provider, etc.). Once you've provided the hostname that RDS gives you, the rest should just work.