AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi
aws.iot.getRegistrationCode
Explore with Pulumi AI
Gets a registration code used to register a CA certificate with AWS IoT.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as tls from "@pulumi/tls";
const example = aws.iot.getRegistrationCode({});
const verification = new tls.PrivateKey("verification", {algorithm: "RSA"});
const verificationCertRequest = new tls.CertRequest("verification", {
keyAlgorithm: "RSA",
privateKeyPem: verification.privateKeyPem,
subject: {
commonName: example.then(example => example.registrationCode),
},
});
import pulumi
import pulumi_aws as aws
import pulumi_tls as tls
example = aws.iot.get_registration_code()
verification = tls.PrivateKey("verification", algorithm="RSA")
verification_cert_request = tls.CertRequest("verification",
key_algorithm="RSA",
private_key_pem=verification.private_key_pem,
subject={
"common_name": example.registration_code,
})
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iot"
"github.com/pulumi/pulumi-tls/sdk/v4/go/tls"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := iot.GetRegistrationCode(ctx, map[string]interface{}{}, nil)
if err != nil {
return err
}
verification, err := tls.NewPrivateKey(ctx, "verification", &tls.PrivateKeyArgs{
Algorithm: pulumi.String("RSA"),
})
if err != nil {
return err
}
_, err = tls.NewCertRequest(ctx, "verification", &tls.CertRequestArgs{
KeyAlgorithm: pulumi.String("RSA"),
PrivateKeyPem: verification.PrivateKeyPem,
Subject: &tls.CertRequestSubjectArgs{
CommonName: pulumi.String(example.RegistrationCode),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
using Tls = Pulumi.Tls;
return await Deployment.RunAsync(() =>
{
var example = Aws.Iot.GetRegistrationCode.Invoke();
var verification = new Tls.PrivateKey("verification", new()
{
Algorithm = "RSA",
});
var verificationCertRequest = new Tls.CertRequest("verification", new()
{
KeyAlgorithm = "RSA",
PrivateKeyPem = verification.PrivateKeyPem,
Subject = new Tls.Inputs.CertRequestSubjectArgs
{
CommonName = example.Apply(getRegistrationCodeResult => getRegistrationCodeResult.RegistrationCode),
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iot.IotFunctions;
import com.pulumi.tls.PrivateKey;
import com.pulumi.tls.PrivateKeyArgs;
import com.pulumi.tls.CertRequest;
import com.pulumi.tls.CertRequestArgs;
import com.pulumi.tls.inputs.CertRequestSubjectArgs;
import java.util.List;
import java.util.ArrayList;
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) {
final var example = IotFunctions.getRegistrationCode();
var verification = new PrivateKey("verification", PrivateKeyArgs.builder()
.algorithm("RSA")
.build());
var verificationCertRequest = new CertRequest("verificationCertRequest", CertRequestArgs.builder()
.keyAlgorithm("RSA")
.privateKeyPem(verification.privateKeyPem())
.subject(CertRequestSubjectArgs.builder()
.commonName(example.applyValue(getRegistrationCodeResult -> getRegistrationCodeResult.registrationCode()))
.build())
.build());
}
}
resources:
verification:
type: tls:PrivateKey
properties:
algorithm: RSA
verificationCertRequest:
type: tls:CertRequest
name: verification
properties:
keyAlgorithm: RSA
privateKeyPem: ${verification.privateKeyPem}
subject:
commonName: ${example.registrationCode}
variables:
example:
fn::invoke:
Function: aws:iot:getRegistrationCode
Arguments: {}
Using getRegistrationCode
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getRegistrationCode(opts?: InvokeOptions): Promise<GetRegistrationCodeResult>
function getRegistrationCodeOutput(opts?: InvokeOptions): Output<GetRegistrationCodeResult>
def get_registration_code(opts: Optional[InvokeOptions] = None) -> GetRegistrationCodeResult
def get_registration_code_output(opts: Optional[InvokeOptions] = None) -> Output[GetRegistrationCodeResult]
func GetRegistrationCode(ctx *Context, opts ...InvokeOption) (*GetRegistrationCodeResult, error)
func GetRegistrationCodeOutput(ctx *Context, opts ...InvokeOption) GetRegistrationCodeResultOutput
> Note: This function is named GetRegistrationCode
in the Go SDK.
public static class GetRegistrationCode
{
public static Task<GetRegistrationCodeResult> InvokeAsync(InvokeOptions? opts = null)
public static Output<GetRegistrationCodeResult> Invoke(InvokeOptions? opts = null)
}
public static CompletableFuture<GetRegistrationCodeResult> getRegistrationCode(InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: aws:iot/getRegistrationCode:getRegistrationCode
arguments:
# arguments dictionary
getRegistrationCode Result
The following output properties are available:
- Id string
- The provider-assigned unique ID for this managed resource.
- Registration
Code string - The CA certificate registration code.
- Id string
- The provider-assigned unique ID for this managed resource.
- Registration
Code string - The CA certificate registration code.
- id String
- The provider-assigned unique ID for this managed resource.
- registration
Code String - The CA certificate registration code.
- id string
- The provider-assigned unique ID for this managed resource.
- registration
Code string - The CA certificate registration code.
- id str
- The provider-assigned unique ID for this managed resource.
- registration_
code str - The CA certificate registration code.
- id String
- The provider-assigned unique ID for this managed resource.
- registration
Code String - The CA certificate registration code.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
aws
Terraform Provider.