Nops.Core.AwsKms 1.1.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Nops.Core.AwsKms --version 1.1.0
                    
NuGet\Install-Package Nops.Core.AwsKms -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nops.Core.AwsKms" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nops.Core.AwsKms" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Nops.Core.AwsKms" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nops.Core.AwsKms --version 1.1.0
                    
#r "nuget: Nops.Core.AwsKms, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nops.Core.AwsKms@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nops.Core.AwsKms&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Nops.Core.AwsKms&version=1.1.0
                    
Install as a Cake Tool

Nops.Core.AwsKms

AWS KMS master key provider for Nops - in-process SOPS decryption.

Installation

dotnet add package Nops.Core.AwsKms

Usage

using Nops.Core;
using Nops.Core.Keys;

// Option 1: Default credential chain (environment variables, IMDS, shared config)
var masterKey = new AwsKmsMasterKey(
    arn: "arn:aws:kms:us-east-1:123456789012:key/abcd-1234-5678-efgh",
    context: new List<KeyValuePair<string, string>>
    {
        new KeyValuePair<string, string>("Project", "myapp")
    }
);

// Option 2: Explicit client (useful for LocalStack or custom endpoints)
var client = new AmazonKMSClient(
    new BasicAWSCredentials("AKIAIOSFODNN7EXAMPLE", "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"),
    RegionEndpoint.USEast1
);

var masterKey2 = new AwsKmsMasterKey(
    arn: "arn:aws:kms:us-east-1:123456789012:key/abcd-1234-5678-efgh",
    client: client
);

// Use with SopsFile
var result = await SopsFile.DecryptTreeAsync(
    fileBytes: File.ReadAllBytes("secrets.sops.yaml"),
    fileKind: "yaml",
    options: new SopsOptions
    {
        MasterKeys = new[] { masterKey }
    });

Authentication

AWS KMS uses the AWS SDK default credential chain:

  1. Environment variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN
  2. Shared credentials file: ~/.aws/credentials
  3. IAM role (EC2, ECS, EKS, Lambda)
  4. Amazon Cognito identity

LocalStack Development

docker run -p 4566:4566 localstack/localstack
var client = new AmazonKMSClient(
    new BasicAWSCredentials("test", "test"),
    RegionEndpoint.USEast1)
{
    Config = new AmazonKMSConfig { ServiceURL = "http://localhost:4566" }
};

IAM Permissions

Minimum IAM policy for KMS decrypt:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "kms:Decrypt",
      "Resource": "arn:aws:kms:<region>:<account>:key/<key-id>"
    }
  ]
}

If using encryption context, the same policy applies - context matching is enforced at decrypt time.

Encryption Context Mapping

SOPS stores encryption context as key-value pairs in .sops.kms[].context. These must match exactly what was used during encryption:

sops:
  kms:
    - arn: arn:aws:kms:us-east-1:123456789012:key/abcd-1234
      enc: BASE64_ENCODED_SHARE
      context:
        Project: myapp
        Environment: production

When creating AwsKmsMasterKey, pass the same context:

var key = new AwsKmsMasterKey(
    arn: "arn:aws:kms:us-east-1:123456789012:key/abcd-1234",
    context: new[] { 
        new KeyValuePair<string, string>("Project", "myapp"),
        new KeyValuePair<string, string>("Environment", "production") 
    }
);

Running Tests

Unit tests run without dependencies:

dotnet test tests/Nops.Core.AwsKms.Tests --filter FullyQualifiedName~AwsKmsEntryParserTests

Integration tests need a KMS endpoint (for example LocalStack, started as shown above):

AWS_LIVE_TEST=1 dotnet test tests/Nops.Core.AwsKms.Tests --filter FullyQualifiedName~AwsKmsIntegrationTests

License

MIT - see LICENSE.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 112 10/25/2026
1.1.0 106 10/25/2026
1.0.0 114 10/25/2026
1.0.0-preview.1 84 10/10/2026