github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/transfer/sshKey.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 transfer
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"errors"
    11  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    12  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    13  )
    14  
    15  // Provides a AWS Transfer User SSH Key resource.
    16  //
    17  // ## Example Usage
    18  //
    19  // <!--Start PulumiCodeChooser -->
    20  // ```go
    21  // package main
    22  //
    23  // import (
    24  //
    25  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    26  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/transfer"
    27  //	"github.com/pulumi/pulumi-std/sdk/go/std"
    28  //	"github.com/pulumi/pulumi-tls/sdk/v4/go/tls"
    29  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    30  //
    31  // )
    32  //
    33  //	func main() {
    34  //		pulumi.Run(func(ctx *pulumi.Context) error {
    35  //			examplePrivateKey, err := tls.NewPrivateKey(ctx, "example", &tls.PrivateKeyArgs{
    36  //				Algorithm: pulumi.String("RSA"),
    37  //				RsaBits:   pulumi.Int(4096),
    38  //			})
    39  //			if err != nil {
    40  //				return err
    41  //			}
    42  //			exampleServer, err := transfer.NewServer(ctx, "example", &transfer.ServerArgs{
    43  //				IdentityProviderType: pulumi.String("SERVICE_MANAGED"),
    44  //				Tags: pulumi.StringMap{
    45  //					"NAME": pulumi.String("tf-acc-test-transfer-server"),
    46  //				},
    47  //			})
    48  //			if err != nil {
    49  //				return err
    50  //			}
    51  //			assumeRole, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
    52  //				Statements: []iam.GetPolicyDocumentStatement{
    53  //					{
    54  //						Effect: pulumi.StringRef("Allow"),
    55  //						Principals: []iam.GetPolicyDocumentStatementPrincipal{
    56  //							{
    57  //								Type: "Service",
    58  //								Identifiers: []string{
    59  //									"transfer.amazonaws.com",
    60  //								},
    61  //							},
    62  //						},
    63  //						Actions: []string{
    64  //							"sts:AssumeRole",
    65  //						},
    66  //					},
    67  //				},
    68  //			}, nil)
    69  //			if err != nil {
    70  //				return err
    71  //			}
    72  //			exampleRole, err := iam.NewRole(ctx, "example", &iam.RoleArgs{
    73  //				Name:             pulumi.String("tf-test-transfer-user-iam-role"),
    74  //				AssumeRolePolicy: pulumi.String(assumeRole.Json),
    75  //			})
    76  //			if err != nil {
    77  //				return err
    78  //			}
    79  //			exampleUser, err := transfer.NewUser(ctx, "example", &transfer.UserArgs{
    80  //				ServerId: exampleServer.ID(),
    81  //				UserName: pulumi.String("tftestuser"),
    82  //				Role:     exampleRole.Arn,
    83  //				Tags: pulumi.StringMap{
    84  //					"NAME": pulumi.String("tftestuser"),
    85  //				},
    86  //			})
    87  //			if err != nil {
    88  //				return err
    89  //			}
    90  //			_, err = transfer.NewSshKey(ctx, "example", &transfer.SshKeyArgs{
    91  //				ServerId: exampleServer.ID(),
    92  //				UserName: exampleUser.UserName,
    93  //				Body: std.TrimspaceOutput(ctx, std.TrimspaceOutputArgs{
    94  //					Input: examplePrivateKey.PublicKeyOpenssh,
    95  //				}, nil).ApplyT(func(invoke std.TrimspaceResult) (*string, error) {
    96  //					return invoke.Result, nil
    97  //				}).(pulumi.StringPtrOutput),
    98  //			})
    99  //			if err != nil {
   100  //				return err
   101  //			}
   102  //			example, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
   103  //				Statements: []iam.GetPolicyDocumentStatement{
   104  //					{
   105  //						Sid:    pulumi.StringRef("AllowFullAccesstoS3"),
   106  //						Effect: pulumi.StringRef("Allow"),
   107  //						Actions: []string{
   108  //							"s3:*",
   109  //						},
   110  //						Resources: []string{
   111  //							"*",
   112  //						},
   113  //					},
   114  //				},
   115  //			}, nil)
   116  //			if err != nil {
   117  //				return err
   118  //			}
   119  //			_, err = iam.NewRolePolicy(ctx, "example", &iam.RolePolicyArgs{
   120  //				Name:   pulumi.String("tf-test-transfer-user-iam-policy"),
   121  //				Role:   exampleRole.ID(),
   122  //				Policy: pulumi.String(example.Json),
   123  //			})
   124  //			if err != nil {
   125  //				return err
   126  //			}
   127  //			return nil
   128  //		})
   129  //	}
   130  //
   131  // ```
   132  // <!--End PulumiCodeChooser -->
   133  //
   134  // ## Import
   135  //
   136  // Using `pulumi import`, import Transfer SSH Public Key using the `server_id` and `user_name` and `ssh_public_key_id` separated by `/`. For example:
   137  //
   138  // ```sh
   139  // $ pulumi import aws:transfer/sshKey:SshKey bar s-12345678/test-username/key-12345
   140  // ```
   141  type SshKey struct {
   142  	pulumi.CustomResourceState
   143  
   144  	// The public key portion of an SSH key pair.
   145  	Body pulumi.StringOutput `pulumi:"body"`
   146  	// The Server ID of the Transfer Server (e.g., `s-12345678`)
   147  	ServerId pulumi.StringOutput `pulumi:"serverId"`
   148  	// The name of the user account that is assigned to one or more servers.
   149  	UserName pulumi.StringOutput `pulumi:"userName"`
   150  }
   151  
   152  // NewSshKey registers a new resource with the given unique name, arguments, and options.
   153  func NewSshKey(ctx *pulumi.Context,
   154  	name string, args *SshKeyArgs, opts ...pulumi.ResourceOption) (*SshKey, error) {
   155  	if args == nil {
   156  		return nil, errors.New("missing one or more required arguments")
   157  	}
   158  
   159  	if args.Body == nil {
   160  		return nil, errors.New("invalid value for required argument 'Body'")
   161  	}
   162  	if args.ServerId == nil {
   163  		return nil, errors.New("invalid value for required argument 'ServerId'")
   164  	}
   165  	if args.UserName == nil {
   166  		return nil, errors.New("invalid value for required argument 'UserName'")
   167  	}
   168  	opts = internal.PkgResourceDefaultOpts(opts)
   169  	var resource SshKey
   170  	err := ctx.RegisterResource("aws:transfer/sshKey:SshKey", name, args, &resource, opts...)
   171  	if err != nil {
   172  		return nil, err
   173  	}
   174  	return &resource, nil
   175  }
   176  
   177  // GetSshKey gets an existing SshKey resource's state with the given name, ID, and optional
   178  // state properties that are used to uniquely qualify the lookup (nil if not required).
   179  func GetSshKey(ctx *pulumi.Context,
   180  	name string, id pulumi.IDInput, state *SshKeyState, opts ...pulumi.ResourceOption) (*SshKey, error) {
   181  	var resource SshKey
   182  	err := ctx.ReadResource("aws:transfer/sshKey:SshKey", name, id, state, &resource, opts...)
   183  	if err != nil {
   184  		return nil, err
   185  	}
   186  	return &resource, nil
   187  }
   188  
   189  // Input properties used for looking up and filtering SshKey resources.
   190  type sshKeyState struct {
   191  	// The public key portion of an SSH key pair.
   192  	Body *string `pulumi:"body"`
   193  	// The Server ID of the Transfer Server (e.g., `s-12345678`)
   194  	ServerId *string `pulumi:"serverId"`
   195  	// The name of the user account that is assigned to one or more servers.
   196  	UserName *string `pulumi:"userName"`
   197  }
   198  
   199  type SshKeyState struct {
   200  	// The public key portion of an SSH key pair.
   201  	Body pulumi.StringPtrInput
   202  	// The Server ID of the Transfer Server (e.g., `s-12345678`)
   203  	ServerId pulumi.StringPtrInput
   204  	// The name of the user account that is assigned to one or more servers.
   205  	UserName pulumi.StringPtrInput
   206  }
   207  
   208  func (SshKeyState) ElementType() reflect.Type {
   209  	return reflect.TypeOf((*sshKeyState)(nil)).Elem()
   210  }
   211  
   212  type sshKeyArgs struct {
   213  	// The public key portion of an SSH key pair.
   214  	Body string `pulumi:"body"`
   215  	// The Server ID of the Transfer Server (e.g., `s-12345678`)
   216  	ServerId string `pulumi:"serverId"`
   217  	// The name of the user account that is assigned to one or more servers.
   218  	UserName string `pulumi:"userName"`
   219  }
   220  
   221  // The set of arguments for constructing a SshKey resource.
   222  type SshKeyArgs struct {
   223  	// The public key portion of an SSH key pair.
   224  	Body pulumi.StringInput
   225  	// The Server ID of the Transfer Server (e.g., `s-12345678`)
   226  	ServerId pulumi.StringInput
   227  	// The name of the user account that is assigned to one or more servers.
   228  	UserName pulumi.StringInput
   229  }
   230  
   231  func (SshKeyArgs) ElementType() reflect.Type {
   232  	return reflect.TypeOf((*sshKeyArgs)(nil)).Elem()
   233  }
   234  
   235  type SshKeyInput interface {
   236  	pulumi.Input
   237  
   238  	ToSshKeyOutput() SshKeyOutput
   239  	ToSshKeyOutputWithContext(ctx context.Context) SshKeyOutput
   240  }
   241  
   242  func (*SshKey) ElementType() reflect.Type {
   243  	return reflect.TypeOf((**SshKey)(nil)).Elem()
   244  }
   245  
   246  func (i *SshKey) ToSshKeyOutput() SshKeyOutput {
   247  	return i.ToSshKeyOutputWithContext(context.Background())
   248  }
   249  
   250  func (i *SshKey) ToSshKeyOutputWithContext(ctx context.Context) SshKeyOutput {
   251  	return pulumi.ToOutputWithContext(ctx, i).(SshKeyOutput)
   252  }
   253  
   254  // SshKeyArrayInput is an input type that accepts SshKeyArray and SshKeyArrayOutput values.
   255  // You can construct a concrete instance of `SshKeyArrayInput` via:
   256  //
   257  //	SshKeyArray{ SshKeyArgs{...} }
   258  type SshKeyArrayInput interface {
   259  	pulumi.Input
   260  
   261  	ToSshKeyArrayOutput() SshKeyArrayOutput
   262  	ToSshKeyArrayOutputWithContext(context.Context) SshKeyArrayOutput
   263  }
   264  
   265  type SshKeyArray []SshKeyInput
   266  
   267  func (SshKeyArray) ElementType() reflect.Type {
   268  	return reflect.TypeOf((*[]*SshKey)(nil)).Elem()
   269  }
   270  
   271  func (i SshKeyArray) ToSshKeyArrayOutput() SshKeyArrayOutput {
   272  	return i.ToSshKeyArrayOutputWithContext(context.Background())
   273  }
   274  
   275  func (i SshKeyArray) ToSshKeyArrayOutputWithContext(ctx context.Context) SshKeyArrayOutput {
   276  	return pulumi.ToOutputWithContext(ctx, i).(SshKeyArrayOutput)
   277  }
   278  
   279  // SshKeyMapInput is an input type that accepts SshKeyMap and SshKeyMapOutput values.
   280  // You can construct a concrete instance of `SshKeyMapInput` via:
   281  //
   282  //	SshKeyMap{ "key": SshKeyArgs{...} }
   283  type SshKeyMapInput interface {
   284  	pulumi.Input
   285  
   286  	ToSshKeyMapOutput() SshKeyMapOutput
   287  	ToSshKeyMapOutputWithContext(context.Context) SshKeyMapOutput
   288  }
   289  
   290  type SshKeyMap map[string]SshKeyInput
   291  
   292  func (SshKeyMap) ElementType() reflect.Type {
   293  	return reflect.TypeOf((*map[string]*SshKey)(nil)).Elem()
   294  }
   295  
   296  func (i SshKeyMap) ToSshKeyMapOutput() SshKeyMapOutput {
   297  	return i.ToSshKeyMapOutputWithContext(context.Background())
   298  }
   299  
   300  func (i SshKeyMap) ToSshKeyMapOutputWithContext(ctx context.Context) SshKeyMapOutput {
   301  	return pulumi.ToOutputWithContext(ctx, i).(SshKeyMapOutput)
   302  }
   303  
   304  type SshKeyOutput struct{ *pulumi.OutputState }
   305  
   306  func (SshKeyOutput) ElementType() reflect.Type {
   307  	return reflect.TypeOf((**SshKey)(nil)).Elem()
   308  }
   309  
   310  func (o SshKeyOutput) ToSshKeyOutput() SshKeyOutput {
   311  	return o
   312  }
   313  
   314  func (o SshKeyOutput) ToSshKeyOutputWithContext(ctx context.Context) SshKeyOutput {
   315  	return o
   316  }
   317  
   318  // The public key portion of an SSH key pair.
   319  func (o SshKeyOutput) Body() pulumi.StringOutput {
   320  	return o.ApplyT(func(v *SshKey) pulumi.StringOutput { return v.Body }).(pulumi.StringOutput)
   321  }
   322  
   323  // The Server ID of the Transfer Server (e.g., `s-12345678`)
   324  func (o SshKeyOutput) ServerId() pulumi.StringOutput {
   325  	return o.ApplyT(func(v *SshKey) pulumi.StringOutput { return v.ServerId }).(pulumi.StringOutput)
   326  }
   327  
   328  // The name of the user account that is assigned to one or more servers.
   329  func (o SshKeyOutput) UserName() pulumi.StringOutput {
   330  	return o.ApplyT(func(v *SshKey) pulumi.StringOutput { return v.UserName }).(pulumi.StringOutput)
   331  }
   332  
   333  type SshKeyArrayOutput struct{ *pulumi.OutputState }
   334  
   335  func (SshKeyArrayOutput) ElementType() reflect.Type {
   336  	return reflect.TypeOf((*[]*SshKey)(nil)).Elem()
   337  }
   338  
   339  func (o SshKeyArrayOutput) ToSshKeyArrayOutput() SshKeyArrayOutput {
   340  	return o
   341  }
   342  
   343  func (o SshKeyArrayOutput) ToSshKeyArrayOutputWithContext(ctx context.Context) SshKeyArrayOutput {
   344  	return o
   345  }
   346  
   347  func (o SshKeyArrayOutput) Index(i pulumi.IntInput) SshKeyOutput {
   348  	return pulumi.All(o, i).ApplyT(func(vs []interface{}) *SshKey {
   349  		return vs[0].([]*SshKey)[vs[1].(int)]
   350  	}).(SshKeyOutput)
   351  }
   352  
   353  type SshKeyMapOutput struct{ *pulumi.OutputState }
   354  
   355  func (SshKeyMapOutput) ElementType() reflect.Type {
   356  	return reflect.TypeOf((*map[string]*SshKey)(nil)).Elem()
   357  }
   358  
   359  func (o SshKeyMapOutput) ToSshKeyMapOutput() SshKeyMapOutput {
   360  	return o
   361  }
   362  
   363  func (o SshKeyMapOutput) ToSshKeyMapOutputWithContext(ctx context.Context) SshKeyMapOutput {
   364  	return o
   365  }
   366  
   367  func (o SshKeyMapOutput) MapIndex(k pulumi.StringInput) SshKeyOutput {
   368  	return pulumi.All(o, k).ApplyT(func(vs []interface{}) *SshKey {
   369  		return vs[0].(map[string]*SshKey)[vs[1].(string)]
   370  	}).(SshKeyOutput)
   371  }
   372  
   373  func init() {
   374  	pulumi.RegisterInputType(reflect.TypeOf((*SshKeyInput)(nil)).Elem(), &SshKey{})
   375  	pulumi.RegisterInputType(reflect.TypeOf((*SshKeyArrayInput)(nil)).Elem(), SshKeyArray{})
   376  	pulumi.RegisterInputType(reflect.TypeOf((*SshKeyMapInput)(nil)).Elem(), SshKeyMap{})
   377  	pulumi.RegisterOutputType(SshKeyOutput{})
   378  	pulumi.RegisterOutputType(SshKeyArrayOutput{})
   379  	pulumi.RegisterOutputType(SshKeyMapOutput{})
   380  }