File tree Expand file tree Collapse file tree 6 files changed +147
-0
lines changed
multi-arch-builders/provisioning/aarch64 Expand file tree Collapse file tree 6 files changed +147
-0
lines changed Original file line number Diff line number Diff line change 1+ # OpenTofu
2+
3+ OpenTofu is a Terraform fork, is an open-source infrastructure as code (IaC) tool
4+ lets you define both cloud and on-prem resources in human-readable configuration files
5+ that you can version, reuse, and share.
6+
7+ To proceed with the next steps, ensure that 'tofu' is installed on your system.
8+ See: https://github.com/opentofu/opentofu/releases
9+
10+ ## Before starting
11+
12+ ### AWS credentials
13+
14+ ``` bash
15+ # Add your credentials to the environment.
16+ # Be aware for aarch64 the region is us-east-2
17+ HISTCONTROL=' ignoreboth'
18+ export AWS_DEFAULT_REGION=us-east-2
19+ export AWS_ACCESS_KEY_ID=XXXX
20+ export AWS_SECRET_ACCESS_KEY=YYYYYYYY
21+ ```
22+
23+ Make sure your AMI user has access to this policies:
24+
25+ ``` json
26+ {
27+ "Version" : " 2012-10-17" ,
28+ "Statement" : [
29+ {
30+ "Effect" : " Allow" ,
31+ "Action" : " ec2:*" ,
32+ "Resource" : " *"
33+ }
34+ ]
35+ }
36+ ```
37+
38+ ## Running tofu
39+ ``` bash
40+ # To begin using it, run 'init' within this directory.
41+ tofu init
42+ # If you don't intend to make any changes to the code, simply run it:
43+ tofu apply
44+ # If you plan to make changes to the code as modules/plugins, go ahead and run it:
45+ tofu init -upgrade
46+ # To destroy it run:
47+ tofu destroy -target aws_instance.coreos-multiarch-builder-aarch64
48+ ```
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ cat ../../builder-common.bu | butane --pretty --strict > builder-common.ign
4+ cat ../../coreos-aarch64-builder.bu | butane --pretty --strict --files-dir=. > coreos-aarch64-builder.ign
Original file line number Diff line number Diff line change 1+ terraform {
2+ required_providers {
3+ ct = {
4+ source = " poseidon/ct"
5+ version = " 0.13.0"
6+ }
7+ aws = {
8+ source = " hashicorp/aws"
9+ version = " ~> 5.0"
10+ }
11+ http = {
12+ source = " hashicorp/http"
13+ version = " 2.1.0"
14+ }
15+ }
16+ }
17+
18+ provider "aws" {}
19+ provider "ct" {}
20+ provider "http" {}
21+
22+ # Get ignition created for the multiarch builder
23+ resource "null_resource" "butane" {
24+ provisioner "local-exec" {
25+ command = " bash -x ./butane.sh"
26+ }
27+ }
28+
29+ data "aws_region" "aws_region" {}
30+
31+ # Gather information about the AWS image for the current region
32+ data "http" "stream_metadata" {
33+ url = " https://builds.coreos.fedoraproject.org/streams/stable.json"
34+
35+ request_headers = {
36+ Accept = " application/json"
37+ }
38+ }
39+ # Lookup the aarch64 AWS image for the current AWS region
40+ locals {
41+ ami = lookup (jsondecode (data. http . stream_metadata . body ). architectures . aarch64 . images . aws . regions , data. aws_region . aws_region . name ). image
42+ }
43+
44+ resource "aws_instance" "coreos-multiarch-builder-aarch64" {
45+ tags = {
46+ Name = " coreos-aarch64-builder-${ formatdate (" YYYYMMDD" , timestamp ())} "
47+ }
48+ ami = local. ami
49+ user_data = file (" coreos-aarch64-builder.ign" )
50+ instance_type = " m6g.metal"
51+ vpc_security_group_ids = [aws_security_group . sg . id ]
52+ subnet_id = var. aws_subnet_internal
53+ root_block_device {
54+ volume_size = " 200"
55+ volume_type = " gp3"
56+ }
57+ }
58+
59+ output "instance_ip_addr" {
60+ value = aws_instance. coreos-multiarch-builder-aarch64 . private_ip
61+ }
Original file line number Diff line number Diff line change 1+ variable "aws_vpc_prod" {
2+ description = " RHCOS Prod US East 2"
3+ default = " vpc-0e33d95334e362c7e"
4+ }
5+
6+ variable "aws_subnet_internal" {
7+ description = " Internal subnet"
8+ default = " subnet-02014b5e587d01fd2"
9+ }
10+
Original file line number Diff line number Diff line change 1+ resource "aws_security_group" "sg" {
2+ name = " coreos-multiarch-aarch64-security-group"
3+ description = " Allow SSH inbound traffic only"
4+ vpc_id = var. aws_vpc_prod
5+
6+ ingress {
7+ description = " SSH access"
8+ from_port = 22
9+ to_port = 22
10+ protocol = " tcp"
11+ cidr_blocks = [" 0.0.0.0/0" ]
12+ }
13+
14+ egress {
15+ from_port = 0
16+ to_port = 0
17+ protocol = " -1"
18+ cidr_blocks = [" 0.0.0.0/0" ]
19+ }
20+
21+ tags = {
22+ Name = " coreos-multiarch-aarch64-security-group"
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments