sparse-spring-91820
11/04/2021, 10:10 AMprehistoric-activity-61023
11/04/2021, 10:22 AMsparse-spring-91820
11/04/2021, 10:23 AMprehistoric-activity-61023
11/04/2021, 10:23 AM(project) eks-cluster
- (stack) main
(project) other-aws-things
- (stack) prod
- (stack) staging
- (stack) dev
sparse-spring-91820
11/04/2021, 10:24 AMprehistoric-activity-61023
11/04/2021, 10:24 AM(project) all-aws-things
- (stack) eks-cluster
- (stack) prod
- (stack) staging
- (stack) dev
and create config values in such a way that eks-cluster
create EKS cluster and nothing else and the others don’t create the clustersparse-spring-91820
11/04/2021, 10:26 AMeks-cluster
create EKS cluster and nothing else and the others don’t create the cluster"?prehistoric-activity-61023
11/04/2021, 10:27 AMgcp-project-bootstrap
that has something like that.
One stack defines shared GCR project (ECR in GCP) and the rest rely on it.sparse-spring-91820
11/04/2021, 10:27 AMif (stack === prod) {
const autoscaler = ...
}
prehistoric-activity-61023
11/04/2021, 10:28 AMsparse-spring-91820
11/04/2021, 10:28 AMprehistoric-activity-61023
11/04/2021, 10:28 AMconfig:
gcp-project-bootstrap:config:
create_vpc: false
project_folder: <REDACTED>
project_id: <REDACTED>
project_name: <REDACTED>
service_accounts:
- account_id: gh-actions
create_key: true
display_name: Service account for Github Actions to push images to shared GCR
project_roles:
- roles/storage.admin
sparse-spring-91820
11/04/2021, 10:30 AMprehistoric-activity-61023
11/04/2021, 10:30 AMconfig:
gcp-project-bootstrap:config:
default_service_account:
gcr_project_id: <PROJECT_ID_FROM_ABOVE>
project_id: <REDACTED>
project_name: <REDACTED>
activate_apis:
- <http://cloudresourcemanager.googleapis.com|cloudresourcemanager.googleapis.com>
- <http://container.googleapis.com|container.googleapis.com>
- <http://iam.googleapis.com|iam.googleapis.com>
- <http://servicenetworking.googleapis.com|servicenetworking.googleapis.com>
- <http://redis.googleapis.com|redis.googleapis.com>
create_vpc
, if it’s false it doesn’t create a VPC at all (it’s not needed for shared project that only gonna contain GCR)
• if default_service_account.gcr_project_id
is present, it’s gonna grant access to the shared project mentioned thereeks_cluster:
create: boolean
use_existing_one: string
sparse-spring-91820
11/04/2021, 10:34 AMprehistoric-activity-61023
11/04/2021, 10:36 AMsparse-spring-91820
11/04/2021, 10:37 AMprehistoric-activity-61023
11/04/2021, 10:40 AMsparse-spring-91820
11/04/2021, 12:59 PMmodule.exports = { provider: cluster.provider };
but when I try to import that provider and use it in the project B i get unknown provider
error:
const stack = pulumi.getStack();
const mainStack = new pulumi.StackReference('ikovac/st-stack-independent/main');
const provider = mainStack.getOutput('provider');
const ns = new k8s.core.v1.Namespace('namespace', {
metadata: { name: `st-${stack}` }
}, { provider });
const namespace = ns.metadata.name;
prehistoric-activity-61023
11/04/2021, 1:00 PMid
property and was using <resource>.get(…)
methods to get the full object in a project where stack ref is used.sparse-spring-91820
11/04/2021, 1:03 PMnew Provider(name: string, args?: ProviderArgs, opts?: CustomResourceOptions);
?prehistoric-activity-61023
11/04/2021, 1:05 PMkubeconfig
as a parameterkubeconfig
from the “parent” project as an output, import it using StackReference and create a provider againcluster.provider
mentioned above?sparse-spring-91820
11/04/2021, 1:06 PMconst cluster = new eks.Cluster('my-cluster', {
vpcId: vpc.id,
subnetIds: vpc.publicSubnetIds,
desiredCapacity: 1
});
prehistoric-activity-61023
11/04/2021, 1:06 PMsparse-spring-91820
11/04/2021, 1:08 PMprehistoric-activity-61023
11/04/2021, 1:08 PMcluster.provider
should have a property with kubeconfigsparse-spring-91820
11/04/2021, 1:08 PMconst provider = new k8s.Provider('provider', {
kubeconfig: clusterProvider.kubeconfig
});
prehistoric-activity-61023
11/04/2021, 1:18 PMclusterProvider.kubeconfig
is fetched from the other stack)sparse-spring-91820
11/04/2021, 1:19 PMprehistoric-activity-61023
11/04/2021, 1:19 PMid
property and use get method. You might need it some day as well so I’m sharing:current_stack = pulumi.get_stack()
project_bootstrap_stack = pulumi.StackReference(
f"<REDACTED>/gcp-project-bootstrap/{current_stack}"
)
vpc_network = gcp.compute.Network.get(
"vpc-network", id=project_bootstrap_stack.require_output("vpc_network_id")
)
gcp.compute.Network
object instead of just a network_name for examplesparse-spring-91820
11/04/2021, 1:23 PMeks.Cluster.get
it doesn't existprehistoric-activity-61023
11/04/2021, 1:33 PMget
method is available for all resources created by “low-level” libraries. This one wraps the cluster creation and doesn’t expose any get method (yet). If you already managed to share a kubeconfig between the stacks, you might simply ignore this fact (as you can already recreate a provider based on that).sparse-spring-91820
11/04/2021, 1:48 PMI guessYou are totally right! I used wrapper libraries such as eks that doesn't have get method, thanks! 🚀method is available for all resources created by “low-level” librariesget
future-refrigerator-88869
11/04/2021, 3:07 PM