AWS v6.73.0 published on Wednesday, Mar 19, 2025 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.index.PrivateKey("verification", {algorithm: "RSA"});
const verificationCertRequest = new tls.index.CertRequest("verification", {
keyAlgorithm: "RSA",
privateKeyPem: verification.privateKeyPem,
subject: [{
commonName: example.registrationCode,
}],
});
import pulumi
import pulumi_aws as aws
import pulumi_tls as tls
example = aws.iot.get_registration_code()
verification = tls.index.PrivateKey("verification", algorithm=RSA)
verification_cert_request = tls.index.CertRequest("verification",
key_algorithm=RSA,
private_key_pem=verification.private_key_pem,
subject=[{
commonName: 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: "RSA",
})
if err != nil {
return err
}
_, err = tls.NewCertRequest(ctx, "verification", &tls.CertRequestArgs{
KeyAlgorithm: "RSA",
PrivateKeyPem: verification.PrivateKeyPem,
Subject: []map[string]interface{}{
map[string]interface{}{
"commonName": 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.Index.PrivateKey("verification", new()
{
Algorithm = "RSA",
});
var verificationCertRequest = new Tls.Index.CertRequest("verification", new()
{
KeyAlgorithm = "RSA",
PrivateKeyPem = verification.PrivateKeyPem,
Subject = new[]
{
{
{ "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 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(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference))
.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)
public static Output<GetRegistrationCodeResult> getRegistrationCode(InvokeOptions options)
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.