Manages an individual AWS Secrets Manager secret tag. This resource should only be used in cases where AWS Secrets Manager secrets are created outside Terraform (e.g., AWS Secrets Manager secrets managed by other AWS services, such as RDS).
NOTE: This tagging resource should not be combined with the Terraform resource for managing the parent resource. For example, using
aws.secretsmanager.Secretandaws.secretsmanager.Tagto manage tags of the same AWS Secrets Manager secret will cause a perpetual difference where theaws.secretsmanager.Secretresource will try to remove the tag being added by theaws.secretsmanager.Tagresource. However, if the parent resource is created in the same configuration (i.e., if you have no other choice), you should addignore_changes </span>= [tags]in the parent resource’s lifecycle block. This ensures that Terraform ignores differences in tags managed via the separate tagging resource, avoiding the perpetual difference mentioned above.
NOTE: This tagging resource does not use the provider
ignore_tagsconfiguration.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const test = new aws.secretsmanager.Secret("test", {name: "example-secret"});
const testTag = new aws.secretsmanager.Tag("test", {
secretId: test.id,
key: "ExampleKey",
value: "ExampleValue",
});
import pulumi
import pulumi_aws as aws
test = aws.secretsmanager.Secret("test", name="example-secret")
test_tag = aws.secretsmanager.Tag("test",
secret_id=test.id,
key="ExampleKey",
value="ExampleValue")
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/secretsmanager"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
test, err := secretsmanager.NewSecret(ctx, "test", &secretsmanager.SecretArgs{
Name: pulumi.String("example-secret"),
})
if err != nil {
return err
}
_, err = secretsmanager.NewTag(ctx, "test", &secretsmanager.TagArgs{
SecretId: test.ID(),
Key: pulumi.String("ExampleKey"),
Value: pulumi.String("ExampleValue"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var test = new Aws.SecretsManager.Secret("test", new()
{
Name = "example-secret",
});
var testTag = new Aws.SecretsManager.Tag("test", new()
{
SecretId = test.Id,
Key = "ExampleKey",
Value = "ExampleValue",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.secretsmanager.Secret;
import com.pulumi.aws.secretsmanager.SecretArgs;
import com.pulumi.aws.secretsmanager.Tag;
import com.pulumi.aws.secretsmanager.TagArgs;
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 test = new Secret("test", SecretArgs.builder()
.name("example-secret")
.build());
var testTag = new Tag("testTag", TagArgs.builder()
.secretId(test.id())
.key("ExampleKey")
.value("ExampleValue")
.build());
}
}
resources:
test:
type: aws:secretsmanager:Secret
properties:
name: example-secret
testTag:
type: aws:secretsmanager:Tag
name: test
properties:
secretId: ${test.id}
key: ExampleKey
value: ExampleValue
Create Tag Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Tag(name: string, args: TagArgs, opts?: CustomResourceOptions);@overload
def Tag(resource_name: str,
args: TagArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Tag(resource_name: str,
opts: Optional[ResourceOptions] = None,
key: Optional[str] = None,
secret_id: Optional[str] = None,
value: Optional[str] = None,
region: Optional[str] = None)func NewTag(ctx *Context, name string, args TagArgs, opts ...ResourceOption) (*Tag, error)public Tag(string name, TagArgs args, CustomResourceOptions? opts = null)type: aws:secretsmanager:Tag
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 TagArgs
- 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 TagArgs
- 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 TagArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args TagArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args TagArgs
- 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 exampletagResourceResourceFromSecretsmanagertag = new Aws.SecretsManager.Tag("exampletagResourceResourceFromSecretsmanagertag", new()
{
Key = "string",
SecretId = "string",
Value = "string",
Region = "string",
});
example, err := secretsmanager.NewTag(ctx, "exampletagResourceResourceFromSecretsmanagertag", &secretsmanager.TagArgs{
Key: pulumi.String("string"),
SecretId: pulumi.String("string"),
Value: pulumi.String("string"),
Region: pulumi.String("string"),
})
var exampletagResourceResourceFromSecretsmanagertag = new com.pulumi.aws.secretsmanager.Tag("exampletagResourceResourceFromSecretsmanagertag", com.pulumi.aws.secretsmanager.TagArgs.builder()
.key("string")
.secretId("string")
.value("string")
.region("string")
.build());
exampletag_resource_resource_from_secretsmanagertag = aws.secretsmanager.Tag("exampletagResourceResourceFromSecretsmanagertag",
key="string",
secret_id="string",
value="string",
region="string")
const exampletagResourceResourceFromSecretsmanagertag = new aws.secretsmanager.Tag("exampletagResourceResourceFromSecretsmanagertag", {
key: "string",
secretId: "string",
value: "string",
region: "string",
});
type: aws:secretsmanager:Tag
properties:
key: string
region: string
secretId: string
value: string
Tag 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 Tag resource accepts the following input properties:
Outputs
All input properties are implicitly available as output properties. Additionally, the Tag resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing Tag Resource
Get an existing Tag 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?: TagState, opts?: CustomResourceOptions): Tag@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
key: Optional[str] = None,
region: Optional[str] = None,
secret_id: Optional[str] = None,
value: Optional[str] = None) -> Tagfunc GetTag(ctx *Context, name string, id IDInput, state *TagState, opts ...ResourceOption) (*Tag, error)public static Tag Get(string name, Input<string> id, TagState? state, CustomResourceOptions? opts = null)public static Tag get(String name, Output<String> id, TagState state, CustomResourceOptions options)resources: _: type: aws:secretsmanager:Tag 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.
Import
Using pulumi import, import aws.secretsmanager.Tag using the AWS Secrets Manager secret identifier and key, separated by a comma (,). For example:
$ pulumi import aws:secretsmanager/tag:Tag example arn:aws:secretsmanager:us-east-1:123456789012:example-secret,ExampleKey
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.
