or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

account-settings.mdalias-version-management.mdclient-management.mdconcurrency-performance.mdevent-source-mapping.mdfunction-invocation.mdfunction-management.mdfunction-url-management.mdhigh-level-invocation.mdindex.mdlayer-management.mdpermissions-policies.mdruntime-management.mdsecurity-code-signing.mdtagging.mdwaiters-polling.md

tagging.mddocs/

0

# Resource Tagging

1

2

Resource tagging enables metadata management for Lambda functions and resources, supporting organization, cost allocation, access control, and automation workflows.

3

4

## Capabilities

5

6

### Tag Resource

7

8

Adds metadata tags to a Lambda function for organization, cost tracking, and access control.

9

10

```java { .api }

11

/**

12

* Adds tags to a function

13

* @param tagResourceRequest - Request specifying resource ARN and tags to add

14

* @return TagResourceResult confirming successful tagging

15

*/

16

TagResourceResult tagResource(TagResourceRequest tagResourceRequest);

17

```

18

19

**Usage Example:**

20

21

```java

22

import com.amazonaws.services.lambda.*;

23

import com.amazonaws.services.lambda.model.*;

24

import java.util.HashMap;

25

import java.util.Map;

26

27

AWSLambda lambdaClient = AWSLambdaClientBuilder.standard()

28

.withRegion("us-east-1")

29

.build();

30

31

// Add tags to a function

32

Map<String, String> tags = new HashMap<>();

33

tags.put("Environment", "production");

34

tags.put("Team", "backend");

35

tags.put("Project", "user-service");

36

tags.put("CostCenter", "engineering");

37

38

TagResourceRequest tagRequest = new TagResourceRequest()

39

.withResource("arn:aws:lambda:us-east-1:123456789012:function:my-function")

40

.withTags(tags);

41

42

TagResourceResult result = lambdaClient.tagResource(tagRequest);

43

System.out.println("Tags added successfully");

44

```

45

46

### Untag Resource

47

48

Removes specified tags from a Lambda function.

49

50

```java { .api }

51

/**

52

* Removes tags from a function

53

* @param untagResourceRequest - Request specifying resource ARN and tag keys to remove

54

* @return UntagResourceResult confirming successful tag removal

55

*/

56

UntagResourceResult untagResource(UntagResourceRequest untagResourceRequest);

57

```

58

59

**Usage Example:**

60

61

```java

62

import java.util.Arrays;

63

64

// Remove specific tags from a function

65

UntagResourceRequest untagRequest = new UntagResourceRequest()

66

.withResource("arn:aws:lambda:us-east-1:123456789012:function:my-function")

67

.withTagKeys(Arrays.asList("Environment", "OldTag"));

68

69

UntagResourceResult untagResult = lambdaClient.untagResource(untagRequest);

70

System.out.println("Tags removed successfully");

71

```

72

73

### List Tags

74

75

Retrieves all tags associated with a Lambda function.

76

77

```java { .api }

78

/**

79

* Returns a function's tags

80

* @param listTagsRequest - Request specifying the resource ARN

81

* @return ListTagsResult containing all tags for the resource

82

*/

83

ListTagsResult listTags(ListTagsRequest listTagsRequest);

84

```

85

86

**Usage Example:**

87

88

```java

89

// List all tags for a function

90

ListTagsRequest listRequest = new ListTagsRequest()

91

.withResource("arn:aws:lambda:us-east-1:123456789012:function:my-function");

92

93

ListTagsResult listResult = lambdaClient.listTags(listRequest);

94

Map<String, String> functionTags = listResult.getTags();

95

96

System.out.println("Function tags:");

97

for (Map.Entry<String, String> tag : functionTags.entrySet()) {

98

System.out.println(" " + tag.getKey() + ": " + tag.getValue());

99

}

100

```

101

102

## Types

103

104

```java { .api }

105

// Tag resource request

106

public class TagResourceRequest {

107

private String resource;

108

private java.util.Map<String, String> tags;

109

// ... getters and setters

110

}

111

112

// Untag resource request

113

public class UntagResourceRequest {

114

private String resource;

115

private java.util.List<String> tagKeys;

116

// ... getters and setters

117

}

118

119

// List tags request

120

public class ListTagsRequest {

121

private String resource;

122

// ... getters and setters

123

}

124

125

// List tags result

126

public class ListTagsResult {

127

private java.util.Map<String, String> tags;

128

// ... getters and setters

129

}

130

```

131

132

## Tag Best Practices

133

134

**Consistent Naming**: Use consistent tag key naming conventions across your organization.

135

136

**Required Tags**: Implement required tags for cost center, environment, and owner identification.

137

138

**Automation**: Use tags to drive automation workflows and resource lifecycle management.

139

140

**Cost Allocation**: Leverage tags for detailed cost tracking and chargeback processes.

141

142

**Access Control**: Use tag-based IAM policies to control resource access.

143

144

## Tag Limitations

145

146

- Maximum 50 tags per function

147

- Tag keys and values are case-sensitive

148

- Tag keys cannot start with "aws:" (reserved prefix)

149

- Maximum key length: 128 characters

150

- Maximum value length: 256 characters