Skip to content

Instantly share code, notes, and snippets.

@jjasghar
Last active September 29, 2017 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjasghar/9820ab1e2fcbb4a46d2f6f7aad25cf92 to your computer and use it in GitHub Desktop.
Save jjasghar/9820ab1e2fcbb4a46d2f6f7aad25cf92 to your computer and use it in GitHub Desktop.
raise "Missing parameter 'CRED_PATH'. Please read docs at #{__FILE__}" \
unless ENV.key?('CRED_PATH')
my_project = "jj-test-kitchen"
gauth_credential 'mycred' do
action :serviceaccount
path ENV['CRED_PATH'] # e.g. '/path/to/my_account.json'
scopes [
'https://www.googleapis.com/auth/compute'
]
end
gcompute_zone 'us-west1-a' do
action :create
project my_project
credential 'mycred'
end
gcompute_disk 'instance-test-os-1' do
action :create
source_image 'projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts'
zone 'us-west1-a'
project my_project
credential 'mycred'
end
gcompute_network 'mynetwork-test' do
action :create
project my_project
credential 'mycred'
end
gcompute_region 'us-west1' do
action :create
project my_project
credential 'mycred'
end
gcompute_address 'instance-test-ip' do
action :create
region 'us-west1'
project my_project
credential 'mycred'
end
gcompute_machine_type 'n1-standard-1' do
action :create
zone 'us-west1-a'
project my_project
credential 'mycred'
end
gcompute_instance 'instance-test' do
action :create
machine_type 'n1-standard-1'
disks [
{
boot: true,
auto_delete: true,
source: 'instance-test-os-1'
}
]
network_interfaces [
{
network: 'mynetwork-test',
access_configs: [
{
name: 'External NAT',
nat_ip: 'instance-test-ip',
type: 'ONE_TO_ONE_NAT'
}
]
}
]
zone 'us-west1-a'
project my_project
credential 'mycred'
metadata ({
items: [
{ key: 'startup-script-url',
value: 'gs://jj-test-kitchen/boostrap.sh'
}
]
})
tags ({
items: [
'http-server',
'https-server'
]
})
service_accounts [
{ scopes: [ 'https://www.googleapis.com/auth/devstorage.read_only',
'https://www.googleapis.com/auth/logging.write' ] }
]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment