github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/organizations/getOrganization.go (about) 1 // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package organizations 5 6 import ( 7 "context" 8 "reflect" 9 10 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 11 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 12 ) 13 14 // Get information about the organization that the user's account belongs to 15 // 16 // ## Example Usage 17 // 18 // ### List all account IDs for the organization 19 // 20 // <!--Start PulumiCodeChooser --> 21 // ```go 22 // package main 23 // 24 // import ( 25 // 26 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/organizations" 27 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 28 // 29 // ) 30 // 31 // func main() { 32 // pulumi.Run(func(ctx *pulumi.Context) error { 33 // example, err := organizations.LookupOrganization(ctx, nil, nil) 34 // if err != nil { 35 // return err 36 // } 37 // var splat0 []*string 38 // for _, val0 := range example.Accounts { 39 // splat0 = append(splat0, val0.Id) 40 // } 41 // ctx.Export("accountIds", splat0) 42 // return nil 43 // }) 44 // } 45 // 46 // ``` 47 // <!--End PulumiCodeChooser --> 48 // 49 // ### SNS topic that can be interacted by the organization only 50 // 51 // <!--Start PulumiCodeChooser --> 52 // ```go 53 // package main 54 // 55 // import ( 56 // 57 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam" 58 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/organizations" 59 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sns" 60 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 61 // 62 // ) 63 // func main() { 64 // pulumi.Run(func(ctx *pulumi.Context) error { 65 // example, err := organizations.LookupOrganization(ctx, nil, nil); 66 // if err != nil { 67 // return err 68 // } 69 // snsTopic, err := sns.NewTopic(ctx, "sns_topic", &sns.TopicArgs{ 70 // Name: pulumi.String("my-sns-topic"), 71 // }) 72 // if err != nil { 73 // return err 74 // } 75 // snsTopicPolicy := snsTopic.Arn.ApplyT(func(arn string) (iam.GetPolicyDocumentResult, error) { 76 // return iam.GetPolicyDocumentOutput(ctx, iam.GetPolicyDocumentOutputArgs{ 77 // Statements: []iam.GetPolicyDocumentStatement{ 78 // { 79 // Effect: "Allow", 80 // Actions: []string{ 81 // "SNS:Subscribe", 82 // "SNS:Publish", 83 // }, 84 // Conditions: []iam.GetPolicyDocumentStatementCondition{ 85 // { 86 // Test: "StringEquals", 87 // Variable: "aws:PrincipalOrgID", 88 // Values: interface{}{ 89 // example.Id, 90 // }, 91 // }, 92 // }, 93 // Principals: []iam.GetPolicyDocumentStatementPrincipal{ 94 // { 95 // Type: "AWS", 96 // Identifiers: []string{ 97 // "*", 98 // }, 99 // }, 100 // }, 101 // Resources: interface{}{ 102 // arn, 103 // }, 104 // }, 105 // }, 106 // }, nil), nil 107 // }).(iam.GetPolicyDocumentResultOutput) 108 // _, err = sns.NewTopicPolicy(ctx, "sns_topic_policy", &sns.TopicPolicyArgs{ 109 // Arn: snsTopic.Arn, 110 // Policy: snsTopicPolicy.ApplyT(func(snsTopicPolicy iam.GetPolicyDocumentResult) (*string, error) { 111 // return &snsTopicPolicy.Json, nil 112 // }).(pulumi.StringPtrOutput), 113 // }) 114 // if err != nil { 115 // return err 116 // } 117 // return nil 118 // }) 119 // } 120 // ``` 121 // <!--End PulumiCodeChooser --> 122 func LookupOrganization(ctx *pulumi.Context, opts ...pulumi.InvokeOption) (*LookupOrganizationResult, error) { 123 opts = internal.PkgInvokeDefaultOpts(opts) 124 var rv LookupOrganizationResult 125 err := ctx.Invoke("aws:organizations/getOrganization:getOrganization", nil, &rv, opts...) 126 if err != nil { 127 return nil, err 128 } 129 return &rv, nil 130 } 131 132 // A collection of values returned by getOrganization. 133 type LookupOrganizationResult struct { 134 // List of organization accounts including the master account. For a list excluding the master account, see the `nonMasterAccounts` attribute. All elements have these attributes: 135 Accounts []GetOrganizationAccount `pulumi:"accounts"` 136 // ARN of the root 137 Arn string `pulumi:"arn"` 138 // A list of AWS service principal names that have integration enabled with your organization. Organization must have `featureSet` set to `ALL`. For additional information, see the [AWS Organizations User Guide](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_integrate_services.html). 139 AwsServiceAccessPrincipals []string `pulumi:"awsServiceAccessPrincipals"` 140 // A list of Organizations policy types that are enabled in the Organization Root. Organization must have `featureSet` set to `ALL`. For additional information about valid policy types (e.g., `SERVICE_CONTROL_POLICY`), see the [AWS Organizations API Reference](https://docs.aws.amazon.com/organizations/latest/APIReference/API_EnablePolicyType.html). 141 EnabledPolicyTypes []string `pulumi:"enabledPolicyTypes"` 142 // FeatureSet of the organization. 143 FeatureSet string `pulumi:"featureSet"` 144 // The provider-assigned unique ID for this managed resource. 145 Id string `pulumi:"id"` 146 // ARN of the account that is designated as the master account for the organization. 147 MasterAccountArn string `pulumi:"masterAccountArn"` 148 // The email address that is associated with the AWS account that is designated as the master account for the organization. 149 MasterAccountEmail string `pulumi:"masterAccountEmail"` 150 // Unique identifier (ID) of the master account of an organization. 151 MasterAccountId string `pulumi:"masterAccountId"` 152 // Name of the master account of an organization. 153 MasterAccountName string `pulumi:"masterAccountName"` 154 // List of organization accounts excluding the master account. For a list including the master account, see the `accounts` attribute. All elements have these attributes: 155 NonMasterAccounts []GetOrganizationNonMasterAccount `pulumi:"nonMasterAccounts"` 156 // List of organization roots. All elements have these attributes: 157 Roots []GetOrganizationRoot `pulumi:"roots"` 158 } 159 160 func LookupOrganizationOutput(ctx *pulumi.Context, opts ...pulumi.InvokeOption) LookupOrganizationResultOutput { 161 return pulumi.ToOutput(0).ApplyT(func(int) (LookupOrganizationResult, error) { 162 r, err := LookupOrganization(ctx, opts...) 163 var s LookupOrganizationResult 164 if r != nil { 165 s = *r 166 } 167 return s, err 168 }).(LookupOrganizationResultOutput) 169 } 170 171 // A collection of values returned by getOrganization. 172 type LookupOrganizationResultOutput struct{ *pulumi.OutputState } 173 174 func (LookupOrganizationResultOutput) ElementType() reflect.Type { 175 return reflect.TypeOf((*LookupOrganizationResult)(nil)).Elem() 176 } 177 178 func (o LookupOrganizationResultOutput) ToLookupOrganizationResultOutput() LookupOrganizationResultOutput { 179 return o 180 } 181 182 func (o LookupOrganizationResultOutput) ToLookupOrganizationResultOutputWithContext(ctx context.Context) LookupOrganizationResultOutput { 183 return o 184 } 185 186 // List of organization accounts including the master account. For a list excluding the master account, see the `nonMasterAccounts` attribute. All elements have these attributes: 187 func (o LookupOrganizationResultOutput) Accounts() GetOrganizationAccountArrayOutput { 188 return o.ApplyT(func(v LookupOrganizationResult) []GetOrganizationAccount { return v.Accounts }).(GetOrganizationAccountArrayOutput) 189 } 190 191 // ARN of the root 192 func (o LookupOrganizationResultOutput) Arn() pulumi.StringOutput { 193 return o.ApplyT(func(v LookupOrganizationResult) string { return v.Arn }).(pulumi.StringOutput) 194 } 195 196 // A list of AWS service principal names that have integration enabled with your organization. Organization must have `featureSet` set to `ALL`. For additional information, see the [AWS Organizations User Guide](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_integrate_services.html). 197 func (o LookupOrganizationResultOutput) AwsServiceAccessPrincipals() pulumi.StringArrayOutput { 198 return o.ApplyT(func(v LookupOrganizationResult) []string { return v.AwsServiceAccessPrincipals }).(pulumi.StringArrayOutput) 199 } 200 201 // A list of Organizations policy types that are enabled in the Organization Root. Organization must have `featureSet` set to `ALL`. For additional information about valid policy types (e.g., `SERVICE_CONTROL_POLICY`), see the [AWS Organizations API Reference](https://docs.aws.amazon.com/organizations/latest/APIReference/API_EnablePolicyType.html). 202 func (o LookupOrganizationResultOutput) EnabledPolicyTypes() pulumi.StringArrayOutput { 203 return o.ApplyT(func(v LookupOrganizationResult) []string { return v.EnabledPolicyTypes }).(pulumi.StringArrayOutput) 204 } 205 206 // FeatureSet of the organization. 207 func (o LookupOrganizationResultOutput) FeatureSet() pulumi.StringOutput { 208 return o.ApplyT(func(v LookupOrganizationResult) string { return v.FeatureSet }).(pulumi.StringOutput) 209 } 210 211 // The provider-assigned unique ID for this managed resource. 212 func (o LookupOrganizationResultOutput) Id() pulumi.StringOutput { 213 return o.ApplyT(func(v LookupOrganizationResult) string { return v.Id }).(pulumi.StringOutput) 214 } 215 216 // ARN of the account that is designated as the master account for the organization. 217 func (o LookupOrganizationResultOutput) MasterAccountArn() pulumi.StringOutput { 218 return o.ApplyT(func(v LookupOrganizationResult) string { return v.MasterAccountArn }).(pulumi.StringOutput) 219 } 220 221 // The email address that is associated with the AWS account that is designated as the master account for the organization. 222 func (o LookupOrganizationResultOutput) MasterAccountEmail() pulumi.StringOutput { 223 return o.ApplyT(func(v LookupOrganizationResult) string { return v.MasterAccountEmail }).(pulumi.StringOutput) 224 } 225 226 // Unique identifier (ID) of the master account of an organization. 227 func (o LookupOrganizationResultOutput) MasterAccountId() pulumi.StringOutput { 228 return o.ApplyT(func(v LookupOrganizationResult) string { return v.MasterAccountId }).(pulumi.StringOutput) 229 } 230 231 // Name of the master account of an organization. 232 func (o LookupOrganizationResultOutput) MasterAccountName() pulumi.StringOutput { 233 return o.ApplyT(func(v LookupOrganizationResult) string { return v.MasterAccountName }).(pulumi.StringOutput) 234 } 235 236 // List of organization accounts excluding the master account. For a list including the master account, see the `accounts` attribute. All elements have these attributes: 237 func (o LookupOrganizationResultOutput) NonMasterAccounts() GetOrganizationNonMasterAccountArrayOutput { 238 return o.ApplyT(func(v LookupOrganizationResult) []GetOrganizationNonMasterAccount { return v.NonMasterAccounts }).(GetOrganizationNonMasterAccountArrayOutput) 239 } 240 241 // List of organization roots. All elements have these attributes: 242 func (o LookupOrganizationResultOutput) Roots() GetOrganizationRootArrayOutput { 243 return o.ApplyT(func(v LookupOrganizationResult) []GetOrganizationRoot { return v.Roots }).(GetOrganizationRootArrayOutput) 244 } 245 246 func init() { 247 pulumi.RegisterOutputType(LookupOrganizationResultOutput{}) 248 }