sonarqube.UserToken
Explore with Pulumi AI
Provides a Sonarqube User token resource. This can be used to manage Sonarqube User tokens.
Example Usage
Example: create a user, user token and output the token value
import * as pulumi from "@pulumi/pulumi";
import * as sonarqube from "@pulumi/sonarqube";
const user = new sonarqube.User("user", {
loginName: "terraform-test",
password: "secret-sauce37!",
});
const token = new sonarqube.UserToken("token", {loginName: user.loginName});
export const userToken = token.token;
import pulumi
import pulumi_sonarqube as sonarqube
user = sonarqube.User("user",
login_name="terraform-test",
password="secret-sauce37!")
token = sonarqube.UserToken("token", login_name=user.login_name)
pulumi.export("userToken", token.token)
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/sonarqube/sonarqube"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
user, err := sonarqube.NewUser(ctx, "user", &sonarqube.UserArgs{
LoginName: pulumi.String("terraform-test"),
Password: pulumi.String("secret-sauce37!"),
})
if err != nil {
return err
}
token, err := sonarqube.NewUserToken(ctx, "token", &sonarqube.UserTokenArgs{
LoginName: user.LoginName,
})
if err != nil {
return err
}
ctx.Export("userToken", token.Token)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Sonarqube = Pulumi.Sonarqube;
return await Deployment.RunAsync(() =>
{
var user = new Sonarqube.User("user", new()
{
LoginName = "terraform-test",
Password = "secret-sauce37!",
});
var token = new Sonarqube.UserToken("token", new()
{
LoginName = user.LoginName,
});
return new Dictionary<string, object?>
{
["userToken"] = token.Token,
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.sonarqube.User;
import com.pulumi.sonarqube.UserArgs;
import com.pulumi.sonarqube.UserToken;
import com.pulumi.sonarqube.UserTokenArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var user = new User("user", UserArgs.builder()
.loginName("terraform-test")
.password("secret-sauce37!")
.build());
var token = new UserToken("token", UserTokenArgs.builder()
.loginName(user.loginName())
.build());
ctx.export("userToken", token.token());
}
}
resources:
user:
type: sonarqube:User
properties:
loginName: terraform-test
password: secret-sauce37!
token:
type: sonarqube:UserToken
properties:
loginName: ${user.loginName}
outputs:
userToken: ${token.token}
Example: create an expiring global analysis token and output the token value
import * as pulumi from "@pulumi/pulumi";
import * as sonarqube from "@pulumi/sonarqube";
const token = new sonarqube.UserToken("token", {
type: "GLOBAL_ANALYSIS_TOKEN",
expirationDate: "2099-01-01",
});
export const globalAnalysisToken = token.token;
import pulumi
import pulumi_sonarqube as sonarqube
token = sonarqube.UserToken("token",
type="GLOBAL_ANALYSIS_TOKEN",
expiration_date="2099-01-01")
pulumi.export("globalAnalysisToken", token.token)
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/sonarqube/sonarqube"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
token, err := sonarqube.NewUserToken(ctx, "token", &sonarqube.UserTokenArgs{
Type: pulumi.String("GLOBAL_ANALYSIS_TOKEN"),
ExpirationDate: pulumi.String("2099-01-01"),
})
if err != nil {
return err
}
ctx.Export("globalAnalysisToken", token.Token)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Sonarqube = Pulumi.Sonarqube;
return await Deployment.RunAsync(() =>
{
var token = new Sonarqube.UserToken("token", new()
{
Type = "GLOBAL_ANALYSIS_TOKEN",
ExpirationDate = "2099-01-01",
});
return new Dictionary<string, object?>
{
["globalAnalysisToken"] = token.Token,
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.sonarqube.UserToken;
import com.pulumi.sonarqube.UserTokenArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var token = new UserToken("token", UserTokenArgs.builder()
.type("GLOBAL_ANALYSIS_TOKEN")
.expirationDate("2099-01-01")
.build());
ctx.export("globalAnalysisToken", token.token());
}
}
resources:
token:
type: sonarqube:UserToken
properties:
type: GLOBAL_ANALYSIS_TOKEN
expirationDate: 2099-01-01
outputs:
globalAnalysisToken: ${token.token}
Example: create a project, project analysis token, and output the token value
import * as pulumi from "@pulumi/pulumi";
import * as sonarqube from "@pulumi/sonarqube";
const token = new sonarqube.UserToken("token", {
type: "PROJECT_ANALYSIS_TOKEN",
projectKey: "my-project",
});
export const projectAnalysisToken = token.token;
import pulumi
import pulumi_sonarqube as sonarqube
token = sonarqube.UserToken("token",
type="PROJECT_ANALYSIS_TOKEN",
project_key="my-project")
pulumi.export("projectAnalysisToken", token.token)
package main
import (
"github.com/pulumi/pulumi-terraform-provider/sdks/go/sonarqube/sonarqube"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
token, err := sonarqube.NewUserToken(ctx, "token", &sonarqube.UserTokenArgs{
Type: pulumi.String("PROJECT_ANALYSIS_TOKEN"),
ProjectKey: pulumi.String("my-project"),
})
if err != nil {
return err
}
ctx.Export("projectAnalysisToken", token.Token)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Sonarqube = Pulumi.Sonarqube;
return await Deployment.RunAsync(() =>
{
var token = new Sonarqube.UserToken("token", new()
{
Type = "PROJECT_ANALYSIS_TOKEN",
ProjectKey = "my-project",
});
return new Dictionary<string, object?>
{
["projectAnalysisToken"] = token.Token,
};
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.sonarqube.UserToken;
import com.pulumi.sonarqube.UserTokenArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var token = new UserToken("token", UserTokenArgs.builder()
.type("PROJECT_ANALYSIS_TOKEN")
.projectKey("my-project")
.build());
ctx.export("projectAnalysisToken", token.token());
}
}
resources:
token:
type: sonarqube:UserToken
properties:
type: PROJECT_ANALYSIS_TOKEN
projectKey: my-project
outputs:
projectAnalysisToken: ${token.token}
Create UserToken Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new UserToken(name: string, args?: UserTokenArgs, opts?: CustomResourceOptions);
@overload
def UserToken(resource_name: str,
args: Optional[UserTokenArgs] = None,
opts: Optional[ResourceOptions] = None)
@overload
def UserToken(resource_name: str,
opts: Optional[ResourceOptions] = None,
expiration_date: Optional[str] = None,
login_name: Optional[str] = None,
name: Optional[str] = None,
project_key: Optional[str] = None,
type: Optional[str] = None,
user_token_id: Optional[str] = None)
func NewUserToken(ctx *Context, name string, args *UserTokenArgs, opts ...ResourceOption) (*UserToken, error)
public UserToken(string name, UserTokenArgs? args = null, CustomResourceOptions? opts = null)
public UserToken(String name, UserTokenArgs args)
public UserToken(String name, UserTokenArgs args, CustomResourceOptions options)
type: sonarqube:UserToken
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args UserTokenArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args UserTokenArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args UserTokenArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args UserTokenArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args UserTokenArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var userTokenResource = new Sonarqube.UserToken("userTokenResource", new()
{
ExpirationDate = "string",
LoginName = "string",
Name = "string",
ProjectKey = "string",
Type = "string",
UserTokenId = "string",
});
example, err := sonarqube.NewUserToken(ctx, "userTokenResource", &sonarqube.UserTokenArgs{
ExpirationDate: pulumi.String("string"),
LoginName: pulumi.String("string"),
Name: pulumi.String("string"),
ProjectKey: pulumi.String("string"),
Type: pulumi.String("string"),
UserTokenId: pulumi.String("string"),
})
var userTokenResource = new UserToken("userTokenResource", UserTokenArgs.builder()
.expirationDate("string")
.loginName("string")
.name("string")
.projectKey("string")
.type("string")
.userTokenId("string")
.build());
user_token_resource = sonarqube.UserToken("userTokenResource",
expiration_date="string",
login_name="string",
name="string",
project_key="string",
type="string",
user_token_id="string")
const userTokenResource = new sonarqube.UserToken("userTokenResource", {
expirationDate: "string",
loginName: "string",
name: "string",
projectKey: "string",
type: "string",
userTokenId: "string",
});
type: sonarqube:UserToken
properties:
expirationDate: string
loginName: string
name: string
projectKey: string
type: string
userTokenId: string
UserToken Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The UserToken resource accepts the following input properties:
- Expiration
Date string - The expiration date of the token being generated, in ISO 8601 format (YYYY-MM-DD). If not set, default to no expiration.
- Login
Name string - The login name of the User for which the token should be created. If not set, the token is created for the authenticated user. Changing this forces a new resource to be created.
- Name string
- The name of the Token to create. Changing this forces a new resource to be created.
- Project
Key string - The key of the only project that can be analyzed by the PROJECT_ANALYSIS TOKEN being created. Changing this forces a new resource to be created.
- Type string
- The kind of Token to create. Changing this forces a new resource to be created. Possible values are USERTOKEN, GLOBALANALYSISTOKEN, or PROJECTANALYSISTOKEN. Defaults to USERTOKEN. If set to PROJECTANALYSISTOKEN, then the project_key must also be specified.
- User
Token stringId - The ID of this resource.
- Expiration
Date string - The expiration date of the token being generated, in ISO 8601 format (YYYY-MM-DD). If not set, default to no expiration.
- Login
Name string - The login name of the User for which the token should be created. If not set, the token is created for the authenticated user. Changing this forces a new resource to be created.
- Name string
- The name of the Token to create. Changing this forces a new resource to be created.
- Project
Key string - The key of the only project that can be analyzed by the PROJECT_ANALYSIS TOKEN being created. Changing this forces a new resource to be created.
- Type string
- The kind of Token to create. Changing this forces a new resource to be created. Possible values are USERTOKEN, GLOBALANALYSISTOKEN, or PROJECTANALYSISTOKEN. Defaults to USERTOKEN. If set to PROJECTANALYSISTOKEN, then the project_key must also be specified.
- User
Token stringId - The ID of this resource.
- expiration
Date String - The expiration date of the token being generated, in ISO 8601 format (YYYY-MM-DD). If not set, default to no expiration.
- login
Name String - The login name of the User for which the token should be created. If not set, the token is created for the authenticated user. Changing this forces a new resource to be created.
- name String
- The name of the Token to create. Changing this forces a new resource to be created.
- project
Key String - The key of the only project that can be analyzed by the PROJECT_ANALYSIS TOKEN being created. Changing this forces a new resource to be created.
- type String
- The kind of Token to create. Changing this forces a new resource to be created. Possible values are USERTOKEN, GLOBALANALYSISTOKEN, or PROJECTANALYSISTOKEN. Defaults to USERTOKEN. If set to PROJECTANALYSISTOKEN, then the project_key must also be specified.
- user
Token StringId - The ID of this resource.
- expiration
Date string - The expiration date of the token being generated, in ISO 8601 format (YYYY-MM-DD). If not set, default to no expiration.
- login
Name string - The login name of the User for which the token should be created. If not set, the token is created for the authenticated user. Changing this forces a new resource to be created.
- name string
- The name of the Token to create. Changing this forces a new resource to be created.
- project
Key string - The key of the only project that can be analyzed by the PROJECT_ANALYSIS TOKEN being created. Changing this forces a new resource to be created.
- type string
- The kind of Token to create. Changing this forces a new resource to be created. Possible values are USERTOKEN, GLOBALANALYSISTOKEN, or PROJECTANALYSISTOKEN. Defaults to USERTOKEN. If set to PROJECTANALYSISTOKEN, then the project_key must also be specified.
- user
Token stringId - The ID of this resource.
- expiration_
date str - The expiration date of the token being generated, in ISO 8601 format (YYYY-MM-DD). If not set, default to no expiration.
- login_
name str - The login name of the User for which the token should be created. If not set, the token is created for the authenticated user. Changing this forces a new resource to be created.
- name str
- The name of the Token to create. Changing this forces a new resource to be created.
- project_
key str - The key of the only project that can be analyzed by the PROJECT_ANALYSIS TOKEN being created. Changing this forces a new resource to be created.
- type str
- The kind of Token to create. Changing this forces a new resource to be created. Possible values are USERTOKEN, GLOBALANALYSISTOKEN, or PROJECTANALYSISTOKEN. Defaults to USERTOKEN. If set to PROJECTANALYSISTOKEN, then the project_key must also be specified.
- user_
token_ strid - The ID of this resource.
- expiration
Date String - The expiration date of the token being generated, in ISO 8601 format (YYYY-MM-DD). If not set, default to no expiration.
- login
Name String - The login name of the User for which the token should be created. If not set, the token is created for the authenticated user. Changing this forces a new resource to be created.
- name String
- The name of the Token to create. Changing this forces a new resource to be created.
- project
Key String - The key of the only project that can be analyzed by the PROJECT_ANALYSIS TOKEN being created. Changing this forces a new resource to be created.
- type String
- The kind of Token to create. Changing this forces a new resource to be created. Possible values are USERTOKEN, GLOBALANALYSISTOKEN, or PROJECTANALYSISTOKEN. Defaults to USERTOKEN. If set to PROJECTANALYSISTOKEN, then the project_key must also be specified.
- user
Token StringId - The ID of this resource.
Outputs
All input properties are implicitly available as output properties. Additionally, the UserToken resource produces the following output properties:
Look up Existing UserToken Resource
Get an existing UserToken resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: UserTokenState, opts?: CustomResourceOptions): UserToken
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
expiration_date: Optional[str] = None,
login_name: Optional[str] = None,
name: Optional[str] = None,
project_key: Optional[str] = None,
token: Optional[str] = None,
type: Optional[str] = None,
user_token_id: Optional[str] = None) -> UserToken
func GetUserToken(ctx *Context, name string, id IDInput, state *UserTokenState, opts ...ResourceOption) (*UserToken, error)
public static UserToken Get(string name, Input<string> id, UserTokenState? state, CustomResourceOptions? opts = null)
public static UserToken get(String name, Output<String> id, UserTokenState state, CustomResourceOptions options)
resources: _: type: sonarqube:UserToken get: id: ${id}
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Expiration
Date string - The expiration date of the token being generated, in ISO 8601 format (YYYY-MM-DD). If not set, default to no expiration.
- Login
Name string - The login name of the User for which the token should be created. If not set, the token is created for the authenticated user. Changing this forces a new resource to be created.
- Name string
- The name of the Token to create. Changing this forces a new resource to be created.
- Project
Key string - The key of the only project that can be analyzed by the PROJECT_ANALYSIS TOKEN being created. Changing this forces a new resource to be created.
- Token string
- The token value.
- Type string
- The kind of Token to create. Changing this forces a new resource to be created. Possible values are USERTOKEN, GLOBALANALYSISTOKEN, or PROJECTANALYSISTOKEN. Defaults to USERTOKEN. If set to PROJECTANALYSISTOKEN, then the project_key must also be specified.
- User
Token stringId - The ID of this resource.
- Expiration
Date string - The expiration date of the token being generated, in ISO 8601 format (YYYY-MM-DD). If not set, default to no expiration.
- Login
Name string - The login name of the User for which the token should be created. If not set, the token is created for the authenticated user. Changing this forces a new resource to be created.
- Name string
- The name of the Token to create. Changing this forces a new resource to be created.
- Project
Key string - The key of the only project that can be analyzed by the PROJECT_ANALYSIS TOKEN being created. Changing this forces a new resource to be created.
- Token string
- The token value.
- Type string
- The kind of Token to create. Changing this forces a new resource to be created. Possible values are USERTOKEN, GLOBALANALYSISTOKEN, or PROJECTANALYSISTOKEN. Defaults to USERTOKEN. If set to PROJECTANALYSISTOKEN, then the project_key must also be specified.
- User
Token stringId - The ID of this resource.
- expiration
Date String - The expiration date of the token being generated, in ISO 8601 format (YYYY-MM-DD). If not set, default to no expiration.
- login
Name String - The login name of the User for which the token should be created. If not set, the token is created for the authenticated user. Changing this forces a new resource to be created.
- name String
- The name of the Token to create. Changing this forces a new resource to be created.
- project
Key String - The key of the only project that can be analyzed by the PROJECT_ANALYSIS TOKEN being created. Changing this forces a new resource to be created.
- token String
- The token value.
- type String
- The kind of Token to create. Changing this forces a new resource to be created. Possible values are USERTOKEN, GLOBALANALYSISTOKEN, or PROJECTANALYSISTOKEN. Defaults to USERTOKEN. If set to PROJECTANALYSISTOKEN, then the project_key must also be specified.
- user
Token StringId - The ID of this resource.
- expiration
Date string - The expiration date of the token being generated, in ISO 8601 format (YYYY-MM-DD). If not set, default to no expiration.
- login
Name string - The login name of the User for which the token should be created. If not set, the token is created for the authenticated user. Changing this forces a new resource to be created.
- name string
- The name of the Token to create. Changing this forces a new resource to be created.
- project
Key string - The key of the only project that can be analyzed by the PROJECT_ANALYSIS TOKEN being created. Changing this forces a new resource to be created.
- token string
- The token value.
- type string
- The kind of Token to create. Changing this forces a new resource to be created. Possible values are USERTOKEN, GLOBALANALYSISTOKEN, or PROJECTANALYSISTOKEN. Defaults to USERTOKEN. If set to PROJECTANALYSISTOKEN, then the project_key must also be specified.
- user
Token stringId - The ID of this resource.
- expiration_
date str - The expiration date of the token being generated, in ISO 8601 format (YYYY-MM-DD). If not set, default to no expiration.
- login_
name str - The login name of the User for which the token should be created. If not set, the token is created for the authenticated user. Changing this forces a new resource to be created.
- name str
- The name of the Token to create. Changing this forces a new resource to be created.
- project_
key str - The key of the only project that can be analyzed by the PROJECT_ANALYSIS TOKEN being created. Changing this forces a new resource to be created.
- token str
- The token value.
- type str
- The kind of Token to create. Changing this forces a new resource to be created. Possible values are USERTOKEN, GLOBALANALYSISTOKEN, or PROJECTANALYSISTOKEN. Defaults to USERTOKEN. If set to PROJECTANALYSISTOKEN, then the project_key must also be specified.
- user_
token_ strid - The ID of this resource.
- expiration
Date String - The expiration date of the token being generated, in ISO 8601 format (YYYY-MM-DD). If not set, default to no expiration.
- login
Name String - The login name of the User for which the token should be created. If not set, the token is created for the authenticated user. Changing this forces a new resource to be created.
- name String
- The name of the Token to create. Changing this forces a new resource to be created.
- project
Key String - The key of the only project that can be analyzed by the PROJECT_ANALYSIS TOKEN being created. Changing this forces a new resource to be created.
- token String
- The token value.
- type String
- The kind of Token to create. Changing this forces a new resource to be created. Possible values are USERTOKEN, GLOBALANALYSISTOKEN, or PROJECTANALYSISTOKEN. Defaults to USERTOKEN. If set to PROJECTANALYSISTOKEN, then the project_key must also be specified.
- user
Token StringId - The ID of this resource.
Package Details
- Repository
- sonarqube jdamata/terraform-provider-sonarqube
- License
- Notes
- This Pulumi package is based on the
sonarqube
Terraform Provider.