These are some more additions to the common errors faced during the authoring and deployment of Infrastructure-as-Code aka IaC artifacts along with their resolutions:
First, resources might pass the identifier of one to another by
virtue of one being created before the other and in some cases, these
identifiers might not exist during compile time. For example, the code that
requires to assign an rbac based on the managed identity of another resource
might not have it during compile time and only find it when it is created
during execution time. The rbac IaC will require a principal _id for which the
managed identity of the resource created is required. This might require two
passes of the execution – one to generate the rbac principal id and another to
generate the role assignment with that principal id.
The above works for newly created resources with two passes but it
is still broken for existing resources that might not have an associated
managed identity and the rbac IaC tries to apply a principal id when it is
empty. In such cases, no matter how many times the role-assignment is applied,
it will fail due to the incorrect principal id. In this case, the workaround is
to check for the existence of the principal id before it is applied.
A second
type of case occurs when the application requires ip address to be assigned for
explaining the elaborate firewall rules required based on ip address value
rather than references and the ip address is provisioned in the portal before
the IaC is applied. This IaC then requires to import the existing pre-created
ip address into the state so that the IaC and the state match.
Third,
there may be objects in the Key Vault that were created as part of the
prerequisites for the IaC deployment and now their ids need to be reconciled
with the IaC. Again, the import of that resource into the state would help the
IaC provider to reconcile the actual with the expected resource.
Fourth, the friendly names are often references to actual
resources that may have long been dereferenced, orphaned, changed, expired, or
even deleted. The friendly names, also called keys, are just references and
hold value to the author in a particular context but the same author might not
guarantee that the moniker is in fact consistently used unless there are some
validations and review involved.
Fifth, there are always three stages between design and deploy of
Infrastructure-as-code which are “init”, “plan” and “apply” and they are
distinct. Success in one stage does not guarantee success in the other stage
especially holding true between plan and apply stages. Another limitation
is that the plan can be easily validated on the development machine but the
apply stage can be performed only as part of pipeline jobs in commercial
deployments. The workaround is to scope it down or target a different environment
for applying.
Sixth, the ordering and sequence can only be partially manifested
with corresponding attributes to explain dependencies between resources. Even
if resources are self-descriptive, combination of resources must be carefully
put-together by the system for a deterministic outcome.
No comments:
Post a Comment