The gitlab.UserAvatar resource allows users to manage the lifecycle of a user avatar.
The resource can also be used to set the avatar on project or group access tokens, as well as on service accounts.
The
tokenattribute is optional only when the GitLab token used by the provider has an administrator scope, as this allows an administrator to manage user avatars.
The provided
tokenmust have theapiscope in order to set the avatar.
Upstream API: GitLab API docs
Create UserAvatar Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new UserAvatar(name: string, args: UserAvatarArgs, opts?: CustomResourceOptions);@overload
def UserAvatar(resource_name: str,
args: UserAvatarArgs,
opts: Optional[ResourceOptions] = None)
@overload
def UserAvatar(resource_name: str,
opts: Optional[ResourceOptions] = None,
avatar: Optional[str] = None,
user_id: Optional[int] = None,
avatar_hash: Optional[str] = None,
token: Optional[str] = None)func NewUserAvatar(ctx *Context, name string, args UserAvatarArgs, opts ...ResourceOption) (*UserAvatar, error)public UserAvatar(string name, UserAvatarArgs args, CustomResourceOptions? opts = null)
public UserAvatar(String name, UserAvatarArgs args)
public UserAvatar(String name, UserAvatarArgs args, CustomResourceOptions options)
type: gitlab:UserAvatar
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 UserAvatarArgs
- 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 UserAvatarArgs
- 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 UserAvatarArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args UserAvatarArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args UserAvatarArgs
- 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 userAvatarResource = new GitLab.UserAvatar("userAvatarResource", new()
{
Avatar = "string",
UserId = 0,
AvatarHash = "string",
Token = "string",
});
example, err := gitlab.NewUserAvatar(ctx, "userAvatarResource", &gitlab.UserAvatarArgs{
Avatar: pulumi.String("string"),
UserId: pulumi.Int(0),
AvatarHash: pulumi.String("string"),
Token: pulumi.String("string"),
})
var userAvatarResource = new UserAvatar("userAvatarResource", UserAvatarArgs.builder()
.avatar("string")
.userId(0)
.avatarHash("string")
.token("string")
.build());
user_avatar_resource = gitlab.UserAvatar("userAvatarResource",
avatar="string",
user_id=0,
avatar_hash="string",
token="string")
const userAvatarResource = new gitlab.UserAvatar("userAvatarResource", {
avatar: "string",
userId: 0,
avatarHash: "string",
token: "string",
});
type: gitlab:UserAvatar
properties:
avatar: string
avatarHash: string
token: string
userId: 0
UserAvatar 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 UserAvatar resource accepts the following input properties:
- Avatar string
- A local path to the avatar image to upload. Note: the avatar is not available for imported resources.
- User
Id int - The ID of the user.
- Avatar
Hash string - The hash of the avatar image. This is used to track changes to the avatar image if the image contents change but the image name remains the same. Use
filesha256("path/to/avatar.png")whenever possible. - Token string
- The access token of the user. If this field is omitted, a GitLab token with administrator scope is required to manage the avatar for the specified user. Note: the token is not available for imported resources.
- Avatar string
- A local path to the avatar image to upload. Note: the avatar is not available for imported resources.
- User
Id int - The ID of the user.
- Avatar
Hash string - The hash of the avatar image. This is used to track changes to the avatar image if the image contents change but the image name remains the same. Use
filesha256("path/to/avatar.png")whenever possible. - Token string
- The access token of the user. If this field is omitted, a GitLab token with administrator scope is required to manage the avatar for the specified user. Note: the token is not available for imported resources.
- avatar String
- A local path to the avatar image to upload. Note: the avatar is not available for imported resources.
- user
Id Integer - The ID of the user.
- avatar
Hash String - The hash of the avatar image. This is used to track changes to the avatar image if the image contents change but the image name remains the same. Use
filesha256("path/to/avatar.png")whenever possible. - token String
- The access token of the user. If this field is omitted, a GitLab token with administrator scope is required to manage the avatar for the specified user. Note: the token is not available for imported resources.
- avatar string
- A local path to the avatar image to upload. Note: the avatar is not available for imported resources.
- user
Id number - The ID of the user.
- avatar
Hash string - The hash of the avatar image. This is used to track changes to the avatar image if the image contents change but the image name remains the same. Use
filesha256("path/to/avatar.png")whenever possible. - token string
- The access token of the user. If this field is omitted, a GitLab token with administrator scope is required to manage the avatar for the specified user. Note: the token is not available for imported resources.
- avatar str
- A local path to the avatar image to upload. Note: the avatar is not available for imported resources.
- user_
id int - The ID of the user.
- avatar_
hash str - The hash of the avatar image. This is used to track changes to the avatar image if the image contents change but the image name remains the same. Use
filesha256("path/to/avatar.png")whenever possible. - token str
- The access token of the user. If this field is omitted, a GitLab token with administrator scope is required to manage the avatar for the specified user. Note: the token is not available for imported resources.
- avatar String
- A local path to the avatar image to upload. Note: the avatar is not available for imported resources.
- user
Id Number - The ID of the user.
- avatar
Hash String - The hash of the avatar image. This is used to track changes to the avatar image if the image contents change but the image name remains the same. Use
filesha256("path/to/avatar.png")whenever possible. - token String
- The access token of the user. If this field is omitted, a GitLab token with administrator scope is required to manage the avatar for the specified user. Note: the token is not available for imported resources.
Outputs
All input properties are implicitly available as output properties. Additionally, the UserAvatar resource produces the following output properties:
- avatar_
url str - The URL of the avatar image.
- id str
- The provider-assigned unique ID for this managed resource.
Look up Existing UserAvatar Resource
Get an existing UserAvatar 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?: UserAvatarState, opts?: CustomResourceOptions): UserAvatar@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
avatar: Optional[str] = None,
avatar_hash: Optional[str] = None,
avatar_url: Optional[str] = None,
token: Optional[str] = None,
user_id: Optional[int] = None) -> UserAvatarfunc GetUserAvatar(ctx *Context, name string, id IDInput, state *UserAvatarState, opts ...ResourceOption) (*UserAvatar, error)public static UserAvatar Get(string name, Input<string> id, UserAvatarState? state, CustomResourceOptions? opts = null)public static UserAvatar get(String name, Output<String> id, UserAvatarState state, CustomResourceOptions options)resources: _: type: gitlab:UserAvatar 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.
- Avatar string
- A local path to the avatar image to upload. Note: the avatar is not available for imported resources.
- Avatar
Hash string - The hash of the avatar image. This is used to track changes to the avatar image if the image contents change but the image name remains the same. Use
filesha256("path/to/avatar.png")whenever possible. - Avatar
Url string - The URL of the avatar image.
- Token string
- The access token of the user. If this field is omitted, a GitLab token with administrator scope is required to manage the avatar for the specified user. Note: the token is not available for imported resources.
- User
Id int - The ID of the user.
- Avatar string
- A local path to the avatar image to upload. Note: the avatar is not available for imported resources.
- Avatar
Hash string - The hash of the avatar image. This is used to track changes to the avatar image if the image contents change but the image name remains the same. Use
filesha256("path/to/avatar.png")whenever possible. - Avatar
Url string - The URL of the avatar image.
- Token string
- The access token of the user. If this field is omitted, a GitLab token with administrator scope is required to manage the avatar for the specified user. Note: the token is not available for imported resources.
- User
Id int - The ID of the user.
- avatar String
- A local path to the avatar image to upload. Note: the avatar is not available for imported resources.
- avatar
Hash String - The hash of the avatar image. This is used to track changes to the avatar image if the image contents change but the image name remains the same. Use
filesha256("path/to/avatar.png")whenever possible. - avatar
Url String - The URL of the avatar image.
- token String
- The access token of the user. If this field is omitted, a GitLab token with administrator scope is required to manage the avatar for the specified user. Note: the token is not available for imported resources.
- user
Id Integer - The ID of the user.
- avatar string
- A local path to the avatar image to upload. Note: the avatar is not available for imported resources.
- avatar
Hash string - The hash of the avatar image. This is used to track changes to the avatar image if the image contents change but the image name remains the same. Use
filesha256("path/to/avatar.png")whenever possible. - avatar
Url string - The URL of the avatar image.
- token string
- The access token of the user. If this field is omitted, a GitLab token with administrator scope is required to manage the avatar for the specified user. Note: the token is not available for imported resources.
- user
Id number - The ID of the user.
- avatar str
- A local path to the avatar image to upload. Note: the avatar is not available for imported resources.
- avatar_
hash str - The hash of the avatar image. This is used to track changes to the avatar image if the image contents change but the image name remains the same. Use
filesha256("path/to/avatar.png")whenever possible. - avatar_
url str - The URL of the avatar image.
- token str
- The access token of the user. If this field is omitted, a GitLab token with administrator scope is required to manage the avatar for the specified user. Note: the token is not available for imported resources.
- user_
id int - The ID of the user.
- avatar String
- A local path to the avatar image to upload. Note: the avatar is not available for imported resources.
- avatar
Hash String - The hash of the avatar image. This is used to track changes to the avatar image if the image contents change but the image name remains the same. Use
filesha256("path/to/avatar.png")whenever possible. - avatar
Url String - The URL of the avatar image.
- token String
- The access token of the user. If this field is omitted, a GitLab token with administrator scope is required to manage the avatar for the specified user. Note: the token is not available for imported resources.
- user
Id Number - The ID of the user.
Import
Starting in Terraform v1.5.0, you can use an import block to import gitlab_user_avatar. For example:
terraform
import {
to = gitlab_user_avatar.example
id = “see CLI command below for ID”
}
Importing using the CLI is supported with the following syntax:
A GitLab User Avatar can be imported using the user id, e.g.
$ pulumi import gitlab:index/userAvatar:UserAvatar example "12345"
NOTE: the token and avatar resource attributes are not available for imported resources as this information cannot be read from the GitLab API.
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- GitLab pulumi/pulumi-gitlab
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
gitlabTerraform Provider.
