Package com.pulumi.aws.transfer
Class SshKey
- java.lang.Object
-
- com.pulumi.resources.Resource
-
- com.pulumi.resources.CustomResource
-
- com.pulumi.aws.transfer.SshKey
-
public class SshKey extends com.pulumi.resources.CustomResourceProvides a AWS Transfer User SSH Key resource. ## Example Usage
## Import Using `pulumi import`, import Transfer SSH Public Key using the `serverId` and `userName` and `sshPublicKeyId` separated by `/`. For example: ```sh $ pulumi import aws:transfer/sshKey:SshKey bar s-12345678/test-username/key-12345 ```package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.tls.PrivateKey; import com.pulumi.tls.PrivateKeyArgs; import com.pulumi.aws.transfer.Server; import com.pulumi.aws.transfer.ServerArgs; import com.pulumi.aws.iam.IamFunctions; import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs; import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs; import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs; import com.pulumi.aws.iam.Role; import com.pulumi.aws.iam.RoleArgs; import com.pulumi.aws.transfer.User; import com.pulumi.aws.transfer.UserArgs; import com.pulumi.aws.transfer.SshKey; import com.pulumi.aws.transfer.SshKeyArgs; import com.pulumi.std.StdFunctions; import com.pulumi.std.inputs.TrimspaceArgs; import com.pulumi.aws.iam.RolePolicy; import com.pulumi.aws.iam.RolePolicyArgs; import java.util.ArrayList; import java.util.Arrays; 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 examplePrivateKey = new PrivateKey("examplePrivateKey", PrivateKeyArgs.builder() .algorithm("RSA") .rsaBits(4096) .build()); var exampleServer = new Server("exampleServer", ServerArgs.builder() .identityProviderType("SERVICE_MANAGED") .tags(Map.of("NAME", "tf-acc-test-transfer-server")) .build()); final var assumeRole = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder() .statements(GetPolicyDocumentStatementArgs.builder() .principals(GetPolicyDocumentStatementPrincipalArgs.builder() .type("Service") .identifiers("transfer.amazonaws.com") .build()) .effect("Allow") .actions("sts:AssumeRole") .build()) .build()); var exampleRole = new Role("exampleRole", RoleArgs.builder() .name("tf-test-transfer-user-iam-role") .assumeRolePolicy(assumeRole.json()) .build()); var exampleUser = new User("exampleUser", UserArgs.builder() .serverId(exampleServer.id()) .userName("tftestuser") .role(exampleRole.arn()) .tags(Map.of("NAME", "tftestuser")) .build()); var exampleSshKey = new SshKey("exampleSshKey", SshKeyArgs.builder() .serverId(exampleServer.id()) .userName(exampleUser.userName()) .body(StdFunctions.trimspace(TrimspaceArgs.builder() .input(examplePrivateKey.publicKeyOpenssh()) .build()).applyValue(_invoke -> _invoke.result())) .build()); final var example = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder() .statements(GetPolicyDocumentStatementArgs.builder() .sid("AllowFullAccesstoS3") .effect("Allow") .actions("s3:*") .resources("*") .build()) .build()); var exampleRolePolicy = new RolePolicy("exampleRolePolicy", RolePolicyArgs.builder() .name("tf-test-transfer-user-iam-policy") .role(exampleRole.id()) .policy(example.json()) .build()); } }
-
-
Constructor Summary
Constructors Constructor Description SshKey(java.lang.String name)SshKey(java.lang.String name, SshKeyArgs args)SshKey(java.lang.String name, SshKeyArgs args, com.pulumi.resources.CustomResourceOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.pulumi.core.Output<java.lang.String>body()static SshKeyget(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, SshKeyState state, com.pulumi.resources.CustomResourceOptions options)Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.com.pulumi.core.Output<java.lang.String>region()com.pulumi.core.Output<java.lang.String>serverId()com.pulumi.core.Output<java.lang.String>sshKeyId()com.pulumi.core.Output<java.lang.String>userName()
-
-
-
Constructor Detail
-
SshKey
public SshKey(java.lang.String name)
- Parameters:
name- The _unique_ name of the resulting resource.
-
SshKey
public SshKey(java.lang.String name, SshKeyArgs args)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.
-
SshKey
public SshKey(java.lang.String name, SshKeyArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.options- A bag of options that control this resource's behavior.
-
-
Method Detail
-
body
public com.pulumi.core.Output<java.lang.String> body()
- Returns:
- Public key portion of an SSH key pair.
-
region
public com.pulumi.core.Output<java.lang.String> region()
- Returns:
- Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
-
serverId
public com.pulumi.core.Output<java.lang.String> serverId()
- Returns:
- Server ID of the Transfer Server (e.g., `s-12345678`)
-
sshKeyId
public com.pulumi.core.Output<java.lang.String> sshKeyId()
- Returns:
- ID of the SSH public key.
-
userName
public com.pulumi.core.Output<java.lang.String> userName()
- Returns:
- Name of the user account that is assigned to one or more servers.
-
get
public static SshKey get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, @Nullable SshKeyState state, @Nullable com.pulumi.resources.CustomResourceOptions options)
Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.- Parameters:
name- The _unique_ name of the resulting resource.id- The _unique_ provider ID of the resource to lookup.state-options- Optional settings to control the behavior of the CustomResource.
-
-