-
Notifications
You must be signed in to change notification settings - Fork 17
/
awscdk_Arn.go
154 lines (134 loc) · 4.57 KB
/
awscdk_Arn.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// An experiment to bundle the entire CDK into a single module
package awscdk
import (
_init_ "github.com/aws/aws-cdk-go/awscdk/jsii"
_jsii_ "github.com/aws/jsii-runtime-go/runtime"
)
// Experimental.
type Arn interface {
}
// The jsii proxy struct for Arn
type jsiiProxy_Arn struct {
_ byte // padding
}
// Extract the full resource name from an ARN.
//
// Necessary for resource names (paths) that may contain the separator, like
// `arn:aws:iam::111111111111:role/path/to/role/name`.
//
// Only works if we statically know the expected `resourceType` beforehand, since we're going
// to use that to split the string on ':<resourceType>/' (and take the right-hand side).
//
// We can't extract the 'resourceType' from the ARN at hand, because CloudFormation Expressions
// only allow literals in the 'separator' argument to `{ Fn::Split }`, and so it can't be
// `{ Fn::Select: [5, { Fn::Split: [':', ARN] }}`.
//
// Only necessary for ARN formats for which the type-name separator is `/`.
// Experimental.
func Arn_ExtractResourceName(arn *string, resourceType *string) *string {
_init_.Initialize()
if err := validateArn_ExtractResourceNameParameters(arn, resourceType); err != nil {
panic(err)
}
var returns *string
_jsii_.StaticInvoke(
"monocdk.Arn",
"extractResourceName",
[]interface{}{arn, resourceType},
&returns,
)
return returns
}
// Creates an ARN from components.
//
// If `partition`, `region` or `account` are not specified, the stack's
// partition, region and account will be used.
//
// If any component is the empty string, an empty string will be inserted
// into the generated ARN at the location that component corresponds to.
//
// The ARN will be formatted as follows:
//
// arn:{partition}:{service}:{region}:{account}:{resource}{sep}{resource-name}
//
// The required ARN pieces that are omitted will be taken from the stack that
// the 'scope' is attached to. If all ARN pieces are supplied, the supplied scope
// can be 'undefined'.
// Experimental.
func Arn_Format(components *ArnComponents, stack Stack) *string {
_init_.Initialize()
if err := validateArn_FormatParameters(components); err != nil {
panic(err)
}
var returns *string
_jsii_.StaticInvoke(
"monocdk.Arn",
"format",
[]interface{}{components, stack},
&returns,
)
return returns
}
// Given an ARN, parses it and returns components.
//
// IF THE ARN IS A CONCRETE STRING...
//
// ...it will be parsed and validated. The separator (`sep`) will be set to '/'
// if the 6th component includes a '/', in which case, `resource` will be set
// to the value before the '/' and `resourceName` will be the rest. In case
// there is no '/', `resource` will be set to the 6th components and
// `resourceName` will be set to the rest of the string.
//
// IF THE ARN IS A TOKEN...
//
// ...it cannot be validated, since we don't have the actual value yet at the
// time of this function call. You will have to supply `sepIfToken` and
// whether or not ARNs of the expected format usually have resource names
// in order to parse it properly. The resulting `ArnComponents` object will
// contain tokens for the subexpressions of the ARN, not string literals.
//
// If the resource name could possibly contain the separator char, the actual
// resource name cannot be properly parsed. This only occurs if the separator
// char is '/', and happens for example for S3 object ARNs, IAM Role ARNs,
// IAM OIDC Provider ARNs, etc. To properly extract the resource name from a
// Tokenized ARN, you must know the resource type and call
// `Arn.extractResourceName`.
//
// Returns: an ArnComponents object which allows access to the various
// components of the ARN.
// Deprecated: use split instead.
func Arn_Parse(arn *string, sepIfToken *string, hasName *bool) *ArnComponents {
_init_.Initialize()
if err := validateArn_ParseParameters(arn); err != nil {
panic(err)
}
var returns *ArnComponents
_jsii_.StaticInvoke(
"monocdk.Arn",
"parse",
[]interface{}{arn, sepIfToken, hasName},
&returns,
)
return returns
}
// Splits the provided ARN into its components.
//
// Works both if 'arn' is a string like 'arn:aws:s3:::bucket',
// and a Token representing a dynamic CloudFormation expression
// (in which case the returned components will also be dynamic CloudFormation expressions,
// encoded as Tokens).
// Experimental.
func Arn_Split(arn *string, arnFormat ArnFormat) *ArnComponents {
_init_.Initialize()
if err := validateArn_SplitParameters(arn, arnFormat); err != nil {
panic(err)
}
var returns *ArnComponents
_jsii_.StaticInvoke(
"monocdk.Arn",
"split",
[]interface{}{arn, arnFormat},
&returns,
)
return returns
}