-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for CloudHSM codesigning machine (#51)
* Create cloud HSM code signing cluster * Setup separate private network for communicating with the cloud HSM * Setup EC2 machine that has access to the cloud HSM module via the private network
- Loading branch information
Showing
8 changed files
with
177 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
resource "aws_cloudhsm_v2_cluster" "hsm" { | ||
hsm_type = "hsm1.medium" | ||
subnet_ids = [var.subnet_id] | ||
|
||
tags = var.tags | ||
} | ||
|
||
resource "aws_security_group" "hsm" { | ||
vpc_id = var.vpc_id | ||
|
||
ingress { | ||
from_port = 22 | ||
to_port = 22 | ||
protocol = "tcp" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
|
||
ingress { | ||
from_port = 2223 # Port for CloudHSM | ||
to_port = 2225 | ||
protocol = "tcp" | ||
cidr_blocks = [var.subnet_cidr_block] | ||
} | ||
|
||
egress { | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
} | ||
} | ||
|
||
data "aws_ami" "amazon_linux" { | ||
most_recent = true | ||
owners = ["amazon"] | ||
|
||
filter { | ||
name = "name" | ||
values = ["al2023-ami-*"] | ||
} | ||
|
||
filter { | ||
name = "architecture" | ||
values = ["x86_64"] | ||
} | ||
|
||
filter { | ||
name = "virtualization-type" | ||
values = ["hvm"] | ||
} | ||
|
||
} | ||
|
||
resource "aws_instance" "codesign_box" { | ||
ami = data.aws_ami.amazon_linux.id | ||
|
||
key_name = var.key_name | ||
instance_type = "t3.micro" | ||
|
||
subnet_id = var.subnet_id | ||
vpc_security_group_ids = [aws_security_group.hsm.id] | ||
|
||
associate_public_ip_address = true | ||
|
||
user_data = <<-EOF | ||
#!/bin/bash | ||
sudo yum update -y | ||
curl -o cloudhsm.rpm https://s3.amazonaws.com/cloudhsmv2-software/CloudHsmClient/Amzn2023/cloudhsm-cli-latest.amzn2023.x86_64.rpm | ||
sudo yum install -y ./cloudhsm-cli.rpm | ||
rm cloudhsm-cli.rpm | ||
curl -o cloudhsm-pkcs11.rpm https://s3.amazonaws.com/cloudhsmv2-software/CloudHsmClient/Amzn2023/cloudhsm-pkcs11-latest.amzn2023.x86_64.rpm | ||
sudo yum install -y ./cloudhsm-pkcs11.rpm | ||
rm cloudhsm-pkcs11.rpm | ||
EOF | ||
|
||
tags = merge(var.tags, { Name = "codesign-box" }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
output "cloudhsm_cluster_id" { | ||
value = aws_cloudhsm_v2_cluster.hsm.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
variable "aws_region" { | ||
description = "The AWS region to create things in." | ||
default = "eu-central-1" | ||
} | ||
|
||
variable "key_name" { | ||
description = "Name of AWS key pair" | ||
} | ||
|
||
variable "vpc_id" { | ||
description = "the id of the VPC to deploy the instance into" | ||
} | ||
|
||
variable "subnet_id" { | ||
description = "the id of the subnet for the HSM" | ||
type = string | ||
} | ||
|
||
variable "subnet_cidr_block" { | ||
description = "the ids of the subnet of the subnets to deploy the instance into" | ||
type = string | ||
} | ||
|
||
variable "tags" { | ||
description = "tags to apply to the resources" | ||
default = {} | ||
type = map(string) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters