Skip to content

Commit 99af513

Browse files
committed
its orbin time
1 parent 9a534c0 commit 99af513

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

orb.sh.tpl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
set -xeuo pipefail
4+
5+
dnf -y install docker
6+
systemctl enable --now docker
7+
curl -SL https://github.com/docker/compose/releases/latest/download/docker-compose-linux-x86_64 -o /usr/libexec/docker/cli-plugins/docker-compose
8+
chmod +x /usr/libexec/docker/cli-plugins/docker-compose
9+
10+
docker pull netboxlabs/orb-agent:latest
11+
12+
mkdir /opt/orb
13+
cd /opt/orb
14+
15+
cat << 'EOF' > orb.yaml
16+
${orb_yaml}
17+
EOF
18+
19+
echo "docker run -u root -v /opt/orb:/opt/orb/ netboxlabs/orb-agent:latest run -c /opt/orb/orb.yaml" > /opt/orb/scan.sh
20+
chmod +x /opt/orb/scan.sh

orb.tf

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
resource "aws_security_group" "orb" {
2+
vpc_id = module.vpc.vpc_id
3+
}
4+
5+
resource "aws_vpc_security_group_egress_rule" "orb_allow_all_out" {
6+
security_group_id = aws_security_group.orb.id
7+
cidr_ipv4 = "0.0.0.0/0"
8+
ip_protocol = "-1"
9+
}
10+
11+
resource "aws_iam_role" "orb_instance_role" {
12+
assume_role_policy = jsonencode({
13+
Version = "2012-10-17"
14+
Statement = [{
15+
Action = "sts:AssumeRole"
16+
Principal = { Service = "ec2.amazonaws.com" }
17+
Effect = "Allow"
18+
}]
19+
})
20+
}
21+
22+
resource "aws_iam_role_policy_attachment" "orb_ssm_policy_attachment" {
23+
role = aws_iam_role.orb_instance_role.name
24+
policy_arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
25+
}
26+
27+
resource "aws_iam_instance_profile" "orb_instance_profile" {
28+
role = aws_iam_role.orb_instance_role.name
29+
}
30+
31+
resource "aws_instance" "orb_instance" {
32+
ami = data.aws_ssm_parameter.al2023_ami_arm64.value
33+
instance_type = "t4g.large"
34+
subnet_id = module.vpc.public_subnets[0]
35+
vpc_security_group_ids = [aws_security_group.nbc.id]
36+
user_data = templatefile("${path.module}/orb.sh.tpl", { orb_yaml = templatefile("${path.module}/orb.yaml.tpl", { diode_server = aws_instance.nbe_instance.private_ip }) })
37+
associate_public_ip_address = true
38+
iam_instance_profile = aws_iam_instance_profile.orb_instance_profile.name
39+
}
40+
41+
output "orb_ssm_command" {
42+
value = "aws --region us-east-1 ssm start-session --target ${aws_instance.orb_instance.id}"
43+
}

orb.yaml.tpl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
orb:
2+
config_manager:
3+
active: local
4+
backends:
5+
network_discovery:
6+
common:
7+
diode:
8+
target: grpc://${diode_server}:80/diode
9+
client_id: FIXME
10+
client_secret: FIXME
11+
agent_name: orb1
12+
policies:
13+
network_discovery:
14+
public_subnets:
15+
config:
16+
scope:
17+
targets:
18+
- 10.0.1.0/24

0 commit comments

Comments
 (0)