Coder Social home page Coder Social logo

pulumi-mysql's Introduction

Actions Status Slack NPM version Python version NuGet version PkgGoDev License

MySQL Resource Provider

The MySQL resource provider for Pulumi lets you manage MySQL resources in your cloud programs. To use this package, please install the Pulumi CLI first.

Installing

This package is available in many languages in the standard packaging formats.

Node.js (Java/TypeScript)

To use from JavaScript or TypeScript in Node.js, install using either npm:

$ npm install @pulumi/mysql

or yarn:

$ yarn add @pulumi/mysql

Python

To use from Python, install using pip:

$ pip install pulumi_mysql

Go

To use from Go, use go get to grab the latest version of the library

$ go get github.com/pulumi/pulumi-mysql/sdk/v3

.NET

To use from .NET, install using dotnet add package:

$ dotnet add package Pulumi.Mysql

Configuration

The following configuration points are available:

  • mysql:endpoint (required) - The address of the MySQL server to use. Most often a "hostname:port" pair, but may also be an absolute path to a Unix socket when the host OS is Unix-compatible. Can be set via MYSQL_ENDPOINT environment variable.
  • mysql:username (required) - Username to use to authenticate with the server. Can be set via MYSQL_USERNAME environment variable.
  • mysql:password - (optional) Password for the given user, if that user has a password. Can be set via MYSQL_PASSWORD environment variable.
  • mysql:tls - (optional) The TLS configuration. One of false, true, or skip-verify. Defaults to false. Can be set via MYSQL_TLS_CONFIG environment variable.
  • mysql:proxy - (Optional) Proxy socks url, can also be sourced from ALL_PROXY or all_proxy environment variables.

Reference

For further information, please visit the MySQL provider docs or for detailed reference documentation, please visit the API docs.

pulumi-mysql's People

Contributors

aaronfriel avatar chrsmith avatar cyrusnajmabadi avatar dependabot[bot] avatar ellismg avatar guineveresaenger avatar iwahbe avatar jaxxstorm avatar jazzyfresh avatar jen20 avatar jkodroff avatar lukehoban avatar mikhailshilkov avatar pgavlin avatar pulumi-bot avatar stack72 avatar t0yv0 avatar viveklak avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pulumi-mysql's Issues

MySQL Grant always causes a difference

What happened?

It appears that the mysql grant resource diff is not showing up as we expect.

Steps to reproduce

import * as mysql from "@pulumi/mysql";

const user = "sample";

export const grant = new mysql.Grant(`mysql-grant-${user}`, {
    database: "sample-db",
    user,
    host: "%",
    privileges: [
      "SELECT",
    ],
}, { ignoreChanges: ["roles"] });
$ pulumi up --refresh
Previewing update (dev):
     Type                     Name                            Plan     Info
     pulumi:pulumi:Stack      pulum-dev
     └─ mysql:index:Grant     mysql-grant-sample           [diff: ~privileges]

Outputs:
~ grant: {
    database  : "sample-db"
    grant     : false
    host      : "%"
    id        : "sample@%:`sample-db`"
    privileges: [
        [0]: "SELECT"
    ]
  + roles     : []
    table     : "*"
    tlsOption : "NONE"
    urn       : "urn:pulumi:dev::pulum::mysql:index/grant:Grant::mysql-grant-sample"
    user      : "sample"
}

Resources:
    1 unchanged

Do you want to perform this update?  [Use arrows to move, enter to select, type to filter]
> yes
  no
  details

Expected Behavior

If the apply has already been completed, we expect no differences with pulumi up --refresh.

Actual Behavior

If we create a mysql grant resource, we will always get a difference in the roles attribute when we run pulumi up --refresh.

Output of pulumi about

$ pulumi about
CLI
Version      3.44.3
Go Version   go1.19.2
Go Compiler  gc

Plugins
NAME    VERSION
mysql   3.1.0
nodejs  unknown

Host
OS       darwin
Version  12.6
Arch     arm64

This project is written in nodejs: executable='/Users/username/.nodebrew/current/bin/node' version='v16.17.1'

Current Stack: dev

TYPE                           URN
pulumi:pulumi:Stack            urn:pulumi:dev::pulum::pulumi:pulumi:Stack::pulum-dev
pulumi:providers:mysql         urn:pulumi:dev::pulum::pulumi:providers:mysql::default_3_1_0
mysql:index/grant:Grant        urn:pulumi:dev::pulum::mysql:index/grant:Grant::mysql-grant-sample

Found no pending operations associated with dev

Backend
Name           hostname
URL            file://~
User           username
Organizations

Dependencies:
NAME            VERSION
@pulumi/mysql   3.1.0
@pulumi/pulumi  3.44.3
@types/node     14.18.33

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

Upstream provider is archived, update dependency to community provider

Hello!

  • Vote on this issue by adding a 👍 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

The terraform provider used as the base for this Pulumi provider is archived and no longer supported. In addition, there is no other official MySQL provider in Terraform. I asked in this slack thread if there are any cons on using a community provider that has been the one used most in Terraform community for MySQL, in this case this fork.
This opens the lack of resources for MySQL and adds new base features, like imports for some resources.

WDYT?

Provider generates invalid Proxy (blank)

What happened?

I am using the mysql.NewProvider, without a proxy. This is returning the following error:

     └─ mysql:index:Database    dev_app                         error: could not validate provider configuration: 1 

Diagnostics:
  mysql:index:Database (dev_app):
    error: could not validate provider configuration: 1 error occurred:
        * invalid value for proxy (The proxy URL is not a valid socks url.)

I believe this is due to the fact that the proxy is being default to a blank instead of a nil here:
https://github.com/pulumi/pulumi-mysql/blob/master/sdk/go/mysql/provider.go#L43

This is a generated file, so I did not consider making any kind of PR. For the moment I am just removing that check locally.

Steps to reproduce

Use the explicit provider, without a Proxy set.

Expected Behavior

The provider should not use a proxy, instead of defaulting it to an invalid blank ("") proxy.

Actual Behavior

Based on the error message, I am assuming the blank proxy is invalid further down the chain.

Output of pulumi about

CLI
Version 3.46.0
Go Version go1.19.2
Go Compiler gc

Plugins
NAME VERSION
auth0 2.14.0
aws 5.13.0
awsx 1.0.0-beta.11
docker 3.2.0
go unknown
mysql 3.1.0

Host
OS ubuntu
Version 20.04
Arch x86_64

This project is written in go: executable='/home/matt/.gvm/gos/go1.18/bin/go' version='go version go1.18 linux/amd64'

......

Dependencies:
NAME VERSION
github.com/pulumi/pulumi-auth0/sdk/v2 2.14.0
github.com/pulumi/pulumi-aws/sdk/v5 5.13.0
github.com/pulumi/pulumi-awsx/sdk 1.0.0-beta.11
github.com/pulumi/pulumi-mysql/sdk/v3 3.1.0
github.com/pulumi/pulumi/sdk/v3 3.39.1

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

Prepare for release

Tracking items for release:

  • Depend on the most recent release of the upstream Terraform provider and have mapped all data sources and resources which make sense.
  • Have the various configuration options for the provider listed in the README file such that package consumers can easily find them.
  • Have documentation ready to publish (in the pulumi/docs repo)
  • Have at least one example running in CI against the provider
  • Tag a version and ensure it's published as latest

'protect' does not exist in type 'InstanceArgs'

Following this guide https://www.pulumi.com/blog/managing-your-mysql-databases-with-pulumi/#example-2-using-a-rds-instance it lists protect: true as a property on the instance but it's not available on the interface.

Argument of type '{ engine: string; username: any; password: any; availabilityZone: string; instanceClass: string; allocatedStorage: number; protect: boolean; }' is not assignable to parameter of type 'InstanceArgs'.
  Object literal may only specify known properties, and 'protect' does not exist in type 'InstanceArgs'.ts(2345)

Version: 2.1.2

Looking at the interface I can see deletionProtection available

Mysql grants delete old grants when adding an extra grant

Hello!

  • Vote on this issue by adding a 👍 reaction
  • To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already)

Issue details

When adding a grant with pulumi-mysql like this:

mysql.Grant(f"mysql-grant-{username}",
        database="*",
        user=username,
        host="%",
        privileges=[
            "SELECT",
            "INSERT",
            "UPDATE",
            "DELETE",
            "CREATE",
            "ALTER",
            "INDEX",
            "REFERENCES",
            "PROCESS"
        ],
        opts=pulumi.ResourceOptions(provider=mysql_provider, parent=user)
    )

and adding an extra privilege later all the priviliges set before the update will be removed.

Steps to reproduce

  1. create a privilege set see above.
  2. add another privilege to the list.

pulumi output:

pulumi:pulumi:Stack: (same)
    [urn=urn:pulumi:prod::accounting::pulumi:pulumi:Stack::accounting-prod]
    > pulumi:pulumi:StackReference: (read)
        [id=buckaroo/prod-v1/prod]
        [urn=urn:pulumi:prod::accounting::pulumi:pulumi:StackReference::buckaroo/prod-v1/prod]
        name: "buckaroo/prod-v1/prod"
        ++mysql:index/grant:Grant: (create-replacement)
            [id=iam_admin@%:*]
            [urn=urn:pulumi:prod::accounting::mysql:index/user:User$mysql:index/grant:Grant::mysql-grant-iam_admin]
            [provider=urn:pulumi:prod::accounting::pulumi:providers:mysql::accounting-prod-rds-root-provider::9efc35f9-e93e-4cf7-8d8b-c53456753faa]
          ~ privileges: [
                [0]: <null>
                [1]: <null>
                [2]: <null>
                [3]: <null>
                [4]: <null>
                [5]: <null>
                [6]: <null>
                [7]: <null>
              + [8]: "PROCESS"
            ]
        +-mysql:index/grant:Grant: (replace)
            [id=iam_admin@%:*]
            [urn=urn:pulumi:prod::accounting::mysql:index/user:User$mysql:index/grant:Grant::mysql-grant-iam_admin]
            [provider=urn:pulumi:prod::accounting::pulumi:providers:mysql::accounting-prod-rds-root-provider::9efc35f9-e93e-4cf7-8d8b-c53456753faa]
          ~ privileges: [
                [0]: <null>
                [1]: <null>
                [2]: <null>
                [3]: <null>
                [4]: <null>
                [5]: <null>
                [6]: <null>
                [7]: <null>
              + [8]: "PROCESS"
            ]
        --outputs:--

Expected: A privilege added but initial privileges intact
Actual: old priviliges removed, new privilige added.

Allow using the provider without pre-defined configuration

In many cases we use cloud providers to create a MySQL server. When using services such as RDS, the endpoint, username and password are created right before the databases are created.

If the configuration is not previously set, the following error is thrown:

Previewing update (development):

     Type                 Name                       Plan     Info
     pulumi:pulumi:Stack  mysql-example-development           1 error

Diagnostics:
  pulumi:pulumi:Stack (mysql-example-development):
    error: Missing required configuration variable 'mysql:endpoint'
    	please set a value using the command `pulumi config set mysql:endpoint <value>`

This is the approach mentioned above:

import * as mysql from '@pulumi/mysql';
import * as aws from '@pulumi/aws';


const rds = new aws.rds.Instance('sample', {
  identifier: "sample",
  engine: "mysql",
  username: "rootUser",
  password: "rootPassword",
  dbSubnetGroupName: "xxxxx",
  availabilityZone: "us-east-1b",
  instanceClass: "db.t2.micro",
  allocatedStorage: 20,
  vpcSecurityGroupIds: ['sg-c1cxxxxx'],
  skipFinalSnapshot: true,
});

const mysqlProvider = new mysql.Provider('mysql', {
  endpoint: rds.endpoint,
  username: rds.username,
  password: rds.password.apply(p => p.toString()),
});

const databaase = new mysql.Database('sample', {
  name: 'sample',
}, {
  provider: mysqlProvider
});

Maybe defaulting the configuration to localhost, root and empty password as many tools do could be a good approach. WDYT?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.