Class: Pangea::Architecture
Overview
Abstract declaration of a named infrastructure architecture.
An Architecture is “a named block of declarative infrastructure that, when applied to a synthesizer, produces Terraform JSON”. It deliberately doesn’t couple to any specific synthesizer — the block is evaluated in whatever context “apply“ is handed, so the same Architecture could be re-rendered against a mock synthesizer for tests, a dry-run synthesizer for plan preview, or a real “TerraformSynthesizer“ for apply.
Example:
Pangea.architecture 'my_fleet' do
resource :aws_vpc, 'main' do
cidr_block '10.0.0.0/16'
end
end
The block reaches the synthesizer via “apply“ below; attribute method calls inside the “resource“ block are interpreted by the synthesizer’s own method_missing (see terraform-synthesizer / abstract-synthesizer for the DSL semantics).
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#apply(synth) ⇒ Object
Apply this architecture to a synthesizer.
-
#initialize(name, block) ⇒ Architecture
constructor
A new instance of Architecture.
Constructor Details
#initialize(name, block) ⇒ Architecture
Returns a new instance of Architecture.
46 47 48 49 |
# File 'lib/pangea/architecture.rb', line 46 def initialize(name, block) @name = name @block = block end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
44 45 46 |
# File 'lib/pangea/architecture.rb', line 44 def block @block end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
44 45 46 |
# File 'lib/pangea/architecture.rb', line 44 def name @name end |
Instance Method Details
#apply(synth) ⇒ Object
Apply this architecture to a synthesizer. The block runs in the synthesizer’s context via “instance_eval“ — every resource / variable / output / etc. declared in the block is captured by the synthesizer’s normal method_missing pipeline.
55 56 57 58 |
# File 'lib/pangea/architecture.rb', line 55 def apply(synth) synth.instance_eval(&@block) synth end |