diff --git a/apis/bedrockagent/v1beta1/zz_agent_terraformed.go b/apis/bedrockagent/v1beta1/zz_agent_terraformed.go new file mode 100755 index 0000000000..d673a80d58 --- /dev/null +++ b/apis/bedrockagent/v1beta1/zz_agent_terraformed.go @@ -0,0 +1,129 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by upjet. DO NOT EDIT. + +package v1beta1 + +import ( + "dario.cat/mergo" + "github.com/pkg/errors" + + "github.com/crossplane/upjet/pkg/resource" + "github.com/crossplane/upjet/pkg/resource/json" +) + +// GetTerraformResourceType returns Terraform resource type for this Agent +func (mg *Agent) GetTerraformResourceType() string { + return "aws_bedrockagent_agent" +} + +// GetConnectionDetailsMapping for this Agent +func (tr *Agent) GetConnectionDetailsMapping() map[string]string { + return nil +} + +// GetObservation of this Agent +func (tr *Agent) GetObservation() (map[string]any, error) { + o, err := json.TFParser.Marshal(tr.Status.AtProvider) + if err != nil { + return nil, err + } + base := map[string]any{} + return base, json.TFParser.Unmarshal(o, &base) +} + +// SetObservation for this Agent +func (tr *Agent) SetObservation(obs map[string]any) error { + p, err := json.TFParser.Marshal(obs) + if err != nil { + return err + } + return json.TFParser.Unmarshal(p, &tr.Status.AtProvider) +} + +// GetID returns ID of underlying Terraform resource of this Agent +func (tr *Agent) GetID() string { + if tr.Status.AtProvider.ID == nil { + return "" + } + return *tr.Status.AtProvider.ID +} + +// GetParameters of this Agent +func (tr *Agent) GetParameters() (map[string]any, error) { + p, err := json.TFParser.Marshal(tr.Spec.ForProvider) + if err != nil { + return nil, err + } + base := map[string]any{} + return base, json.TFParser.Unmarshal(p, &base) +} + +// SetParameters for this Agent +func (tr *Agent) SetParameters(params map[string]any) error { + p, err := json.TFParser.Marshal(params) + if err != nil { + return err + } + return json.TFParser.Unmarshal(p, &tr.Spec.ForProvider) +} + +// GetInitParameters of this Agent +func (tr *Agent) GetInitParameters() (map[string]any, error) { + p, err := json.TFParser.Marshal(tr.Spec.InitProvider) + if err != nil { + return nil, err + } + base := map[string]any{} + return base, json.TFParser.Unmarshal(p, &base) +} + +// GetInitParameters of this Agent +func (tr *Agent) GetMergedParameters(shouldMergeInitProvider bool) (map[string]any, error) { + params, err := tr.GetParameters() + if err != nil { + return nil, errors.Wrapf(err, "cannot get parameters for resource '%q'", tr.GetName()) + } + if !shouldMergeInitProvider { + return params, nil + } + + initParams, err := tr.GetInitParameters() + if err != nil { + return nil, errors.Wrapf(err, "cannot get init parameters for resource '%q'", tr.GetName()) + } + + // Note(lsviben): mergo.WithSliceDeepCopy is needed to merge the + // slices from the initProvider to forProvider. As it also sets + // overwrite to true, we need to set it back to false, we don't + // want to overwrite the forProvider fields with the initProvider + // fields. + err = mergo.Merge(¶ms, initParams, mergo.WithSliceDeepCopy, func(c *mergo.Config) { + c.Overwrite = false + }) + if err != nil { + return nil, errors.Wrapf(err, "cannot merge spec.initProvider and spec.forProvider parameters for resource '%q'", tr.GetName()) + } + + return params, nil +} + +// LateInitialize this Agent using its observed tfState. +// returns True if there are any spec changes for the resource. +func (tr *Agent) LateInitialize(attrs []byte) (bool, error) { + params := &AgentParameters{} + if err := json.TFParser.Unmarshal(attrs, params); err != nil { + return false, errors.Wrap(err, "failed to unmarshal Terraform state parameters for late-initialization") + } + opts := []resource.GenericLateInitializerOption{resource.WithZeroValueJSONOmitEmptyFilter(resource.CNameWildcard)} + + li := resource.NewGenericLateInitializer(opts...) + return li.LateInitialize(&tr.Spec.ForProvider, params) +} + +// GetTerraformSchemaVersion returns the associated Terraform schema version +func (tr *Agent) GetTerraformSchemaVersion() int { + return 0 +} diff --git a/apis/bedrockagent/v1beta1/zz_agent_types.go b/apis/bedrockagent/v1beta1/zz_agent_types.go new file mode 100755 index 0000000000..d6ee3eae27 --- /dev/null +++ b/apis/bedrockagent/v1beta1/zz_agent_types.go @@ -0,0 +1,397 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by upjet. DO NOT EDIT. + +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + + v1 "github.com/crossplane/crossplane-runtime/apis/common/v1" +) + +type AgentInitParameters struct { + + // Name of the agent. + AgentName *string `json:"agentName,omitempty" tf:"agent_name,omitempty"` + + // ARN of the IAM role with permissions to invoke API operations on the agent. + // +crossplane:generate:reference:type=github.com/upbound/provider-aws/apis/iam/v1beta1.Role + // +crossplane:generate:reference:extractor=github.com/upbound/provider-aws/config/common.ARNExtractor() + AgentResourceRoleArn *string `json:"agentResourceRoleArn,omitempty" tf:"agent_resource_role_arn,omitempty"` + + // Reference to a Role in iam to populate agentResourceRoleArn. + // +kubebuilder:validation:Optional + AgentResourceRoleArnRef *v1.Reference `json:"agentResourceRoleArnRef,omitempty" tf:"-"` + + // Selector for a Role in iam to populate agentResourceRoleArn. + // +kubebuilder:validation:Optional + AgentResourceRoleArnSelector *v1.Selector `json:"agentResourceRoleArnSelector,omitempty" tf:"-"` + + // ARN of the AWS KMS key that encrypts the agent. + CustomerEncryptionKeyArn *string `json:"customerEncryptionKeyArn,omitempty" tf:"customer_encryption_key_arn,omitempty"` + + // Description of the agent. + Description *string `json:"description,omitempty" tf:"description,omitempty"` + + // Foundation model used for orchestration by the agent. + FoundationModel *string `json:"foundationModel,omitempty" tf:"foundation_model,omitempty"` + + // Number of seconds for which Amazon Bedrock keeps information about a user's conversation with the agent. A user interaction remains active for the amount of time specified. If no conversation occurs during this time, the session expires and Amazon Bedrock deletes any data provided before the timeout. + IdleSessionTTLInSeconds *float64 `json:"idleSessionTtlInSeconds,omitempty" tf:"idle_session_ttl_in_seconds,omitempty"` + + // Instructions that tell the agent what it should do and how it should interact with users. + Instruction *string `json:"instruction,omitempty" tf:"instruction,omitempty"` + + // Whether to prepare the agent after creation or modification. Defaults to true. + PrepareAgent *bool `json:"prepareAgent,omitempty" tf:"prepare_agent,omitempty"` + + // Configurations to override prompt templates in different parts of an agent sequence. For more information, see Advanced prompts. See prompt_override_configuration Block for details. + PromptOverrideConfiguration []PromptOverrideConfigurationInitParameters `json:"promptOverrideConfiguration,omitempty" tf:"prompt_override_configuration,omitempty"` + + // Whether the in-use check is skipped when deleting the agent. + SkipResourceInUseCheck *bool `json:"skipResourceInUseCheck,omitempty" tf:"skip_resource_in_use_check,omitempty"` + + // Key-value map of resource tags. + // +mapType=granular + Tags map[string]*string `json:"tags,omitempty" tf:"tags,omitempty"` +} + +type AgentObservation struct { + + // ARN of the agent. + AgentArn *string `json:"agentArn,omitempty" tf:"agent_arn,omitempty"` + + // Unique identifier of the agent. + AgentID *string `json:"agentId,omitempty" tf:"agent_id,omitempty"` + + // Name of the agent. + AgentName *string `json:"agentName,omitempty" tf:"agent_name,omitempty"` + + // ARN of the IAM role with permissions to invoke API operations on the agent. + AgentResourceRoleArn *string `json:"agentResourceRoleArn,omitempty" tf:"agent_resource_role_arn,omitempty"` + + // Version of the agent. + AgentVersion *string `json:"agentVersion,omitempty" tf:"agent_version,omitempty"` + + // ARN of the AWS KMS key that encrypts the agent. + CustomerEncryptionKeyArn *string `json:"customerEncryptionKeyArn,omitempty" tf:"customer_encryption_key_arn,omitempty"` + + // Description of the agent. + Description *string `json:"description,omitempty" tf:"description,omitempty"` + + // Foundation model used for orchestration by the agent. + FoundationModel *string `json:"foundationModel,omitempty" tf:"foundation_model,omitempty"` + + // Unique identifier of the agent. + ID *string `json:"id,omitempty" tf:"id,omitempty"` + + // Number of seconds for which Amazon Bedrock keeps information about a user's conversation with the agent. A user interaction remains active for the amount of time specified. If no conversation occurs during this time, the session expires and Amazon Bedrock deletes any data provided before the timeout. + IdleSessionTTLInSeconds *float64 `json:"idleSessionTtlInSeconds,omitempty" tf:"idle_session_ttl_in_seconds,omitempty"` + + // Instructions that tell the agent what it should do and how it should interact with users. + Instruction *string `json:"instruction,omitempty" tf:"instruction,omitempty"` + + // Whether to prepare the agent after creation or modification. Defaults to true. + PrepareAgent *bool `json:"prepareAgent,omitempty" tf:"prepare_agent,omitempty"` + + // Configurations to override prompt templates in different parts of an agent sequence. For more information, see Advanced prompts. See prompt_override_configuration Block for details. + PromptOverrideConfiguration []PromptOverrideConfigurationObservation `json:"promptOverrideConfiguration,omitempty" tf:"prompt_override_configuration,omitempty"` + + // Whether the in-use check is skipped when deleting the agent. + SkipResourceInUseCheck *bool `json:"skipResourceInUseCheck,omitempty" tf:"skip_resource_in_use_check,omitempty"` + + // Key-value map of resource tags. + // +mapType=granular + Tags map[string]*string `json:"tags,omitempty" tf:"tags,omitempty"` + + // Map of tags assigned to the resource, including those inherited from the provider default_tags configuration block. + // +mapType=granular + TagsAll map[string]*string `json:"tagsAll,omitempty" tf:"tags_all,omitempty"` +} + +type AgentParameters struct { + + // Name of the agent. + // +kubebuilder:validation:Optional + AgentName *string `json:"agentName,omitempty" tf:"agent_name,omitempty"` + + // ARN of the IAM role with permissions to invoke API operations on the agent. + // +crossplane:generate:reference:type=github.com/upbound/provider-aws/apis/iam/v1beta1.Role + // +crossplane:generate:reference:extractor=github.com/upbound/provider-aws/config/common.ARNExtractor() + // +kubebuilder:validation:Optional + AgentResourceRoleArn *string `json:"agentResourceRoleArn,omitempty" tf:"agent_resource_role_arn,omitempty"` + + // Reference to a Role in iam to populate agentResourceRoleArn. + // +kubebuilder:validation:Optional + AgentResourceRoleArnRef *v1.Reference `json:"agentResourceRoleArnRef,omitempty" tf:"-"` + + // Selector for a Role in iam to populate agentResourceRoleArn. + // +kubebuilder:validation:Optional + AgentResourceRoleArnSelector *v1.Selector `json:"agentResourceRoleArnSelector,omitempty" tf:"-"` + + // ARN of the AWS KMS key that encrypts the agent. + // +kubebuilder:validation:Optional + CustomerEncryptionKeyArn *string `json:"customerEncryptionKeyArn,omitempty" tf:"customer_encryption_key_arn,omitempty"` + + // Description of the agent. + // +kubebuilder:validation:Optional + Description *string `json:"description,omitempty" tf:"description,omitempty"` + + // Foundation model used for orchestration by the agent. + // +kubebuilder:validation:Optional + FoundationModel *string `json:"foundationModel,omitempty" tf:"foundation_model,omitempty"` + + // Number of seconds for which Amazon Bedrock keeps information about a user's conversation with the agent. A user interaction remains active for the amount of time specified. If no conversation occurs during this time, the session expires and Amazon Bedrock deletes any data provided before the timeout. + // +kubebuilder:validation:Optional + IdleSessionTTLInSeconds *float64 `json:"idleSessionTtlInSeconds,omitempty" tf:"idle_session_ttl_in_seconds,omitempty"` + + // Instructions that tell the agent what it should do and how it should interact with users. + // +kubebuilder:validation:Optional + Instruction *string `json:"instruction,omitempty" tf:"instruction,omitempty"` + + // Whether to prepare the agent after creation or modification. Defaults to true. + // +kubebuilder:validation:Optional + PrepareAgent *bool `json:"prepareAgent,omitempty" tf:"prepare_agent,omitempty"` + + // Configurations to override prompt templates in different parts of an agent sequence. For more information, see Advanced prompts. See prompt_override_configuration Block for details. + // +kubebuilder:validation:Optional + PromptOverrideConfiguration []PromptOverrideConfigurationParameters `json:"promptOverrideConfiguration,omitempty" tf:"prompt_override_configuration,omitempty"` + + // Region is the region you'd like your resource to be created in. + // +upjet:crd:field:TFTag=- + // +kubebuilder:validation:Required + Region *string `json:"region" tf:"-"` + + // Whether the in-use check is skipped when deleting the agent. + // +kubebuilder:validation:Optional + SkipResourceInUseCheck *bool `json:"skipResourceInUseCheck,omitempty" tf:"skip_resource_in_use_check,omitempty"` + + // Key-value map of resource tags. + // +kubebuilder:validation:Optional + // +mapType=granular + Tags map[string]*string `json:"tags,omitempty" tf:"tags,omitempty"` +} + +type InferenceConfigurationInitParameters struct { + + // Maximum number of tokens to allow in the generated response. + MaxLength *float64 `json:"maxLength,omitempty" tf:"max_length"` + + // List of stop sequences. A stop sequence is a sequence of characters that causes the model to stop generating the response. + StopSequences []*string `json:"stopSequences,omitempty" tf:"stop_sequences"` + + // Likelihood of the model selecting higher-probability options while generating a response. A lower value makes the model more likely to choose higher-probability options, while a higher value makes the model more likely to choose lower-probability options. + Temperature *float64 `json:"temperature,omitempty" tf:"temperature"` + + // Number of top most-likely candidates, between 0 and 500, from which the model chooses the next token in the sequence. + TopK *float64 `json:"topK,omitempty" tf:"top_k"` + + // Top percentage of the probability distribution of next tokens, between 0 and 1 (denoting 0% and 100%), from which the model chooses the next token in the sequence. + TopP *float64 `json:"topP,omitempty" tf:"top_p"` +} + +type InferenceConfigurationObservation struct { + + // Maximum number of tokens to allow in the generated response. + MaxLength *float64 `json:"maxLength,omitempty" tf:"max_length,omitempty"` + + // List of stop sequences. A stop sequence is a sequence of characters that causes the model to stop generating the response. + StopSequences []*string `json:"stopSequences,omitempty" tf:"stop_sequences,omitempty"` + + // Likelihood of the model selecting higher-probability options while generating a response. A lower value makes the model more likely to choose higher-probability options, while a higher value makes the model more likely to choose lower-probability options. + Temperature *float64 `json:"temperature,omitempty" tf:"temperature,omitempty"` + + // Number of top most-likely candidates, between 0 and 500, from which the model chooses the next token in the sequence. + TopK *float64 `json:"topK,omitempty" tf:"top_k,omitempty"` + + // Top percentage of the probability distribution of next tokens, between 0 and 1 (denoting 0% and 100%), from which the model chooses the next token in the sequence. + TopP *float64 `json:"topP,omitempty" tf:"top_p,omitempty"` +} + +type InferenceConfigurationParameters struct { + + // Maximum number of tokens to allow in the generated response. + // +kubebuilder:validation:Optional + MaxLength *float64 `json:"maxLength,omitempty" tf:"max_length"` + + // List of stop sequences. A stop sequence is a sequence of characters that causes the model to stop generating the response. + // +kubebuilder:validation:Optional + StopSequences []*string `json:"stopSequences,omitempty" tf:"stop_sequences"` + + // Likelihood of the model selecting higher-probability options while generating a response. A lower value makes the model more likely to choose higher-probability options, while a higher value makes the model more likely to choose lower-probability options. + // +kubebuilder:validation:Optional + Temperature *float64 `json:"temperature,omitempty" tf:"temperature"` + + // Number of top most-likely candidates, between 0 and 500, from which the model chooses the next token in the sequence. + // +kubebuilder:validation:Optional + TopK *float64 `json:"topK,omitempty" tf:"top_k"` + + // Top percentage of the probability distribution of next tokens, between 0 and 1 (denoting 0% and 100%), from which the model chooses the next token in the sequence. + // +kubebuilder:validation:Optional + TopP *float64 `json:"topP,omitempty" tf:"top_p"` +} + +type PromptConfigurationsInitParameters struct { + + // prompt template with which to replace the default prompt template. You can use placeholder variables in the base prompt template to customize the prompt. For more information, see Prompt template placeholder variables. + BasePromptTemplate *string `json:"basePromptTemplate,omitempty" tf:"base_prompt_template"` + + // Inference parameters to use when the agent invokes a foundation model in the part of the agent sequence defined by the prompt_type. For more information, see Inference parameters for foundation models. See inference_configuration Block for details. + InferenceConfiguration []InferenceConfigurationInitParameters `json:"inferenceConfiguration,omitempty" tf:"inference_configuration"` + + // Whether to override the default parser Lambda function when parsing the raw foundation model output in the part of the agent sequence defined by the prompt_type. If you set the argument as OVERRIDDEN, the override_lambda argument in the prompt_override_configuration block must be specified with the ARN of a Lambda function. Valid values: DEFAULT, OVERRIDDEN. + ParserMode *string `json:"parserMode,omitempty" tf:"parser_mode"` + + // Whether to override the default prompt template for this prompt_type. Set this argument to OVERRIDDEN to use the prompt that you provide in the base_prompt_template. If you leave it as DEFAULT, the agent uses a default prompt template. Valid values: DEFAULT, OVERRIDDEN. + PromptCreationMode *string `json:"promptCreationMode,omitempty" tf:"prompt_creation_mode"` + + // Whether to allow the agent to carry out the step specified in the prompt_type. If you set this argument to DISABLED, the agent skips that step. Valid Values: ENABLED, DISABLED. + PromptState *string `json:"promptState,omitempty" tf:"prompt_state"` + + // Step in the agent sequence that this prompt configuration applies to. Valid values: PRE_PROCESSING, ORCHESTRATION, POST_PROCESSING, KNOWLEDGE_BASE_RESPONSE_GENERATION. + PromptType *string `json:"promptType,omitempty" tf:"prompt_type"` +} + +type PromptConfigurationsObservation struct { + + // prompt template with which to replace the default prompt template. You can use placeholder variables in the base prompt template to customize the prompt. For more information, see Prompt template placeholder variables. + BasePromptTemplate *string `json:"basePromptTemplate,omitempty" tf:"base_prompt_template,omitempty"` + + // Inference parameters to use when the agent invokes a foundation model in the part of the agent sequence defined by the prompt_type. For more information, see Inference parameters for foundation models. See inference_configuration Block for details. + InferenceConfiguration []InferenceConfigurationObservation `json:"inferenceConfiguration,omitempty" tf:"inference_configuration,omitempty"` + + // Whether to override the default parser Lambda function when parsing the raw foundation model output in the part of the agent sequence defined by the prompt_type. If you set the argument as OVERRIDDEN, the override_lambda argument in the prompt_override_configuration block must be specified with the ARN of a Lambda function. Valid values: DEFAULT, OVERRIDDEN. + ParserMode *string `json:"parserMode,omitempty" tf:"parser_mode,omitempty"` + + // Whether to override the default prompt template for this prompt_type. Set this argument to OVERRIDDEN to use the prompt that you provide in the base_prompt_template. If you leave it as DEFAULT, the agent uses a default prompt template. Valid values: DEFAULT, OVERRIDDEN. + PromptCreationMode *string `json:"promptCreationMode,omitempty" tf:"prompt_creation_mode,omitempty"` + + // Whether to allow the agent to carry out the step specified in the prompt_type. If you set this argument to DISABLED, the agent skips that step. Valid Values: ENABLED, DISABLED. + PromptState *string `json:"promptState,omitempty" tf:"prompt_state,omitempty"` + + // Step in the agent sequence that this prompt configuration applies to. Valid values: PRE_PROCESSING, ORCHESTRATION, POST_PROCESSING, KNOWLEDGE_BASE_RESPONSE_GENERATION. + PromptType *string `json:"promptType,omitempty" tf:"prompt_type,omitempty"` +} + +type PromptConfigurationsParameters struct { + + // prompt template with which to replace the default prompt template. You can use placeholder variables in the base prompt template to customize the prompt. For more information, see Prompt template placeholder variables. + // +kubebuilder:validation:Optional + BasePromptTemplate *string `json:"basePromptTemplate,omitempty" tf:"base_prompt_template"` + + // Inference parameters to use when the agent invokes a foundation model in the part of the agent sequence defined by the prompt_type. For more information, see Inference parameters for foundation models. See inference_configuration Block for details. + // +kubebuilder:validation:Optional + InferenceConfiguration []InferenceConfigurationParameters `json:"inferenceConfiguration,omitempty" tf:"inference_configuration"` + + // Whether to override the default parser Lambda function when parsing the raw foundation model output in the part of the agent sequence defined by the prompt_type. If you set the argument as OVERRIDDEN, the override_lambda argument in the prompt_override_configuration block must be specified with the ARN of a Lambda function. Valid values: DEFAULT, OVERRIDDEN. + // +kubebuilder:validation:Optional + ParserMode *string `json:"parserMode,omitempty" tf:"parser_mode"` + + // Whether to override the default prompt template for this prompt_type. Set this argument to OVERRIDDEN to use the prompt that you provide in the base_prompt_template. If you leave it as DEFAULT, the agent uses a default prompt template. Valid values: DEFAULT, OVERRIDDEN. + // +kubebuilder:validation:Optional + PromptCreationMode *string `json:"promptCreationMode,omitempty" tf:"prompt_creation_mode"` + + // Whether to allow the agent to carry out the step specified in the prompt_type. If you set this argument to DISABLED, the agent skips that step. Valid Values: ENABLED, DISABLED. + // +kubebuilder:validation:Optional + PromptState *string `json:"promptState,omitempty" tf:"prompt_state"` + + // Step in the agent sequence that this prompt configuration applies to. Valid values: PRE_PROCESSING, ORCHESTRATION, POST_PROCESSING, KNOWLEDGE_BASE_RESPONSE_GENERATION. + // +kubebuilder:validation:Optional + PromptType *string `json:"promptType,omitempty" tf:"prompt_type"` +} + +type PromptOverrideConfigurationInitParameters struct { + + // ARN of the Lambda function to use when parsing the raw foundation model output in parts of the agent sequence. If you specify this field, at least one of the prompt_configurations block must contain a parser_mode value that is set to OVERRIDDEN. + OverrideLambda *string `json:"overrideLambda,omitempty" tf:"override_lambda"` + + // Configurations to override a prompt template in one part of an agent sequence. See prompt_configurations Block for details. + PromptConfigurations []PromptConfigurationsInitParameters `json:"promptConfigurations,omitempty" tf:"prompt_configurations"` +} + +type PromptOverrideConfigurationObservation struct { + + // ARN of the Lambda function to use when parsing the raw foundation model output in parts of the agent sequence. If you specify this field, at least one of the prompt_configurations block must contain a parser_mode value that is set to OVERRIDDEN. + OverrideLambda *string `json:"overrideLambda,omitempty" tf:"override_lambda,omitempty"` + + // Configurations to override a prompt template in one part of an agent sequence. See prompt_configurations Block for details. + PromptConfigurations []PromptConfigurationsObservation `json:"promptConfigurations,omitempty" tf:"prompt_configurations,omitempty"` +} + +type PromptOverrideConfigurationParameters struct { + + // ARN of the Lambda function to use when parsing the raw foundation model output in parts of the agent sequence. If you specify this field, at least one of the prompt_configurations block must contain a parser_mode value that is set to OVERRIDDEN. + // +kubebuilder:validation:Optional + OverrideLambda *string `json:"overrideLambda,omitempty" tf:"override_lambda"` + + // Configurations to override a prompt template in one part of an agent sequence. See prompt_configurations Block for details. + // +kubebuilder:validation:Optional + PromptConfigurations []PromptConfigurationsParameters `json:"promptConfigurations,omitempty" tf:"prompt_configurations"` +} + +// AgentSpec defines the desired state of Agent +type AgentSpec struct { + v1.ResourceSpec `json:",inline"` + ForProvider AgentParameters `json:"forProvider"` + // THIS IS A BETA FIELD. It will be honored + // unless the Management Policies feature flag is disabled. + // InitProvider holds the same fields as ForProvider, with the exception + // of Identifier and other resource reference fields. The fields that are + // in InitProvider are merged into ForProvider when the resource is created. + // The same fields are also added to the terraform ignore_changes hook, to + // avoid updating them after creation. This is useful for fields that are + // required on creation, but we do not desire to update them after creation, + // for example because of an external controller is managing them, like an + // autoscaler. + InitProvider AgentInitParameters `json:"initProvider,omitempty"` +} + +// AgentStatus defines the observed state of Agent. +type AgentStatus struct { + v1.ResourceStatus `json:",inline"` + AtProvider AgentObservation `json:"atProvider,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:storageversion + +// Agent is the Schema for the Agents API. +// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" +// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" +// +kubebuilder:printcolumn:name="EXTERNAL-NAME",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name" +// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" +// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,aws} +type Agent struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.agentName) || (has(self.initProvider) && has(self.initProvider.agentName))",message="spec.forProvider.agentName is a required parameter" + // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.foundationModel) || (has(self.initProvider) && has(self.initProvider.foundationModel))",message="spec.forProvider.foundationModel is a required parameter" + Spec AgentSpec `json:"spec"` + Status AgentStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// AgentList contains a list of Agents +type AgentList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Agent `json:"items"` +} + +// Repository type metadata. +var ( + Agent_Kind = "Agent" + Agent_GroupKind = schema.GroupKind{Group: CRDGroup, Kind: Agent_Kind}.String() + Agent_KindAPIVersion = Agent_Kind + "." + CRDGroupVersion.String() + Agent_GroupVersionKind = CRDGroupVersion.WithKind(Agent_Kind) +) + +func init() { + SchemeBuilder.Register(&Agent{}, &AgentList{}) +} diff --git a/apis/bedrockagent/v1beta1/zz_generated.conversion_hubs.go b/apis/bedrockagent/v1beta1/zz_generated.conversion_hubs.go new file mode 100755 index 0000000000..c6a665ee13 --- /dev/null +++ b/apis/bedrockagent/v1beta1/zz_generated.conversion_hubs.go @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by upjet. DO NOT EDIT. + +package v1beta1 + +// Hub marks this type as a conversion hub. +func (tr *Agent) Hub() {} diff --git a/apis/bedrockagent/v1beta1/zz_generated.deepcopy.go b/apis/bedrockagent/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..59f341f7fe --- /dev/null +++ b/apis/bedrockagent/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,778 @@ +//go:build !ignore_autogenerated + +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by controller-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "github.com/crossplane/crossplane-runtime/apis/common/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Agent) DeepCopyInto(out *Agent) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Agent. +func (in *Agent) DeepCopy() *Agent { + if in == nil { + return nil + } + out := new(Agent) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Agent) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AgentInitParameters) DeepCopyInto(out *AgentInitParameters) { + *out = *in + if in.AgentName != nil { + in, out := &in.AgentName, &out.AgentName + *out = new(string) + **out = **in + } + if in.AgentResourceRoleArn != nil { + in, out := &in.AgentResourceRoleArn, &out.AgentResourceRoleArn + *out = new(string) + **out = **in + } + if in.AgentResourceRoleArnRef != nil { + in, out := &in.AgentResourceRoleArnRef, &out.AgentResourceRoleArnRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.AgentResourceRoleArnSelector != nil { + in, out := &in.AgentResourceRoleArnSelector, &out.AgentResourceRoleArnSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } + if in.CustomerEncryptionKeyArn != nil { + in, out := &in.CustomerEncryptionKeyArn, &out.CustomerEncryptionKeyArn + *out = new(string) + **out = **in + } + if in.Description != nil { + in, out := &in.Description, &out.Description + *out = new(string) + **out = **in + } + if in.FoundationModel != nil { + in, out := &in.FoundationModel, &out.FoundationModel + *out = new(string) + **out = **in + } + if in.IdleSessionTTLInSeconds != nil { + in, out := &in.IdleSessionTTLInSeconds, &out.IdleSessionTTLInSeconds + *out = new(float64) + **out = **in + } + if in.Instruction != nil { + in, out := &in.Instruction, &out.Instruction + *out = new(string) + **out = **in + } + if in.PrepareAgent != nil { + in, out := &in.PrepareAgent, &out.PrepareAgent + *out = new(bool) + **out = **in + } + if in.PromptOverrideConfiguration != nil { + in, out := &in.PromptOverrideConfiguration, &out.PromptOverrideConfiguration + *out = make([]PromptOverrideConfigurationInitParameters, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.SkipResourceInUseCheck != nil { + in, out := &in.SkipResourceInUseCheck, &out.SkipResourceInUseCheck + *out = new(bool) + **out = **in + } + if in.Tags != nil { + in, out := &in.Tags, &out.Tags + *out = make(map[string]*string, len(*in)) + for key, val := range *in { + var outVal *string + if val == nil { + (*out)[key] = nil + } else { + inVal := (*in)[key] + in, out := &inVal, &outVal + *out = new(string) + **out = **in + } + (*out)[key] = outVal + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AgentInitParameters. +func (in *AgentInitParameters) DeepCopy() *AgentInitParameters { + if in == nil { + return nil + } + out := new(AgentInitParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AgentList) DeepCopyInto(out *AgentList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Agent, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AgentList. +func (in *AgentList) DeepCopy() *AgentList { + if in == nil { + return nil + } + out := new(AgentList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AgentList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AgentObservation) DeepCopyInto(out *AgentObservation) { + *out = *in + if in.AgentArn != nil { + in, out := &in.AgentArn, &out.AgentArn + *out = new(string) + **out = **in + } + if in.AgentID != nil { + in, out := &in.AgentID, &out.AgentID + *out = new(string) + **out = **in + } + if in.AgentName != nil { + in, out := &in.AgentName, &out.AgentName + *out = new(string) + **out = **in + } + if in.AgentResourceRoleArn != nil { + in, out := &in.AgentResourceRoleArn, &out.AgentResourceRoleArn + *out = new(string) + **out = **in + } + if in.AgentVersion != nil { + in, out := &in.AgentVersion, &out.AgentVersion + *out = new(string) + **out = **in + } + if in.CustomerEncryptionKeyArn != nil { + in, out := &in.CustomerEncryptionKeyArn, &out.CustomerEncryptionKeyArn + *out = new(string) + **out = **in + } + if in.Description != nil { + in, out := &in.Description, &out.Description + *out = new(string) + **out = **in + } + if in.FoundationModel != nil { + in, out := &in.FoundationModel, &out.FoundationModel + *out = new(string) + **out = **in + } + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(string) + **out = **in + } + if in.IdleSessionTTLInSeconds != nil { + in, out := &in.IdleSessionTTLInSeconds, &out.IdleSessionTTLInSeconds + *out = new(float64) + **out = **in + } + if in.Instruction != nil { + in, out := &in.Instruction, &out.Instruction + *out = new(string) + **out = **in + } + if in.PrepareAgent != nil { + in, out := &in.PrepareAgent, &out.PrepareAgent + *out = new(bool) + **out = **in + } + if in.PromptOverrideConfiguration != nil { + in, out := &in.PromptOverrideConfiguration, &out.PromptOverrideConfiguration + *out = make([]PromptOverrideConfigurationObservation, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.SkipResourceInUseCheck != nil { + in, out := &in.SkipResourceInUseCheck, &out.SkipResourceInUseCheck + *out = new(bool) + **out = **in + } + if in.Tags != nil { + in, out := &in.Tags, &out.Tags + *out = make(map[string]*string, len(*in)) + for key, val := range *in { + var outVal *string + if val == nil { + (*out)[key] = nil + } else { + inVal := (*in)[key] + in, out := &inVal, &outVal + *out = new(string) + **out = **in + } + (*out)[key] = outVal + } + } + if in.TagsAll != nil { + in, out := &in.TagsAll, &out.TagsAll + *out = make(map[string]*string, len(*in)) + for key, val := range *in { + var outVal *string + if val == nil { + (*out)[key] = nil + } else { + inVal := (*in)[key] + in, out := &inVal, &outVal + *out = new(string) + **out = **in + } + (*out)[key] = outVal + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AgentObservation. +func (in *AgentObservation) DeepCopy() *AgentObservation { + if in == nil { + return nil + } + out := new(AgentObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AgentParameters) DeepCopyInto(out *AgentParameters) { + *out = *in + if in.AgentName != nil { + in, out := &in.AgentName, &out.AgentName + *out = new(string) + **out = **in + } + if in.AgentResourceRoleArn != nil { + in, out := &in.AgentResourceRoleArn, &out.AgentResourceRoleArn + *out = new(string) + **out = **in + } + if in.AgentResourceRoleArnRef != nil { + in, out := &in.AgentResourceRoleArnRef, &out.AgentResourceRoleArnRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.AgentResourceRoleArnSelector != nil { + in, out := &in.AgentResourceRoleArnSelector, &out.AgentResourceRoleArnSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } + if in.CustomerEncryptionKeyArn != nil { + in, out := &in.CustomerEncryptionKeyArn, &out.CustomerEncryptionKeyArn + *out = new(string) + **out = **in + } + if in.Description != nil { + in, out := &in.Description, &out.Description + *out = new(string) + **out = **in + } + if in.FoundationModel != nil { + in, out := &in.FoundationModel, &out.FoundationModel + *out = new(string) + **out = **in + } + if in.IdleSessionTTLInSeconds != nil { + in, out := &in.IdleSessionTTLInSeconds, &out.IdleSessionTTLInSeconds + *out = new(float64) + **out = **in + } + if in.Instruction != nil { + in, out := &in.Instruction, &out.Instruction + *out = new(string) + **out = **in + } + if in.PrepareAgent != nil { + in, out := &in.PrepareAgent, &out.PrepareAgent + *out = new(bool) + **out = **in + } + if in.PromptOverrideConfiguration != nil { + in, out := &in.PromptOverrideConfiguration, &out.PromptOverrideConfiguration + *out = make([]PromptOverrideConfigurationParameters, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Region != nil { + in, out := &in.Region, &out.Region + *out = new(string) + **out = **in + } + if in.SkipResourceInUseCheck != nil { + in, out := &in.SkipResourceInUseCheck, &out.SkipResourceInUseCheck + *out = new(bool) + **out = **in + } + if in.Tags != nil { + in, out := &in.Tags, &out.Tags + *out = make(map[string]*string, len(*in)) + for key, val := range *in { + var outVal *string + if val == nil { + (*out)[key] = nil + } else { + inVal := (*in)[key] + in, out := &inVal, &outVal + *out = new(string) + **out = **in + } + (*out)[key] = outVal + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AgentParameters. +func (in *AgentParameters) DeepCopy() *AgentParameters { + if in == nil { + return nil + } + out := new(AgentParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AgentSpec) DeepCopyInto(out *AgentSpec) { + *out = *in + in.ResourceSpec.DeepCopyInto(&out.ResourceSpec) + in.ForProvider.DeepCopyInto(&out.ForProvider) + in.InitProvider.DeepCopyInto(&out.InitProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AgentSpec. +func (in *AgentSpec) DeepCopy() *AgentSpec { + if in == nil { + return nil + } + out := new(AgentSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AgentStatus) DeepCopyInto(out *AgentStatus) { + *out = *in + in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) + in.AtProvider.DeepCopyInto(&out.AtProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AgentStatus. +func (in *AgentStatus) DeepCopy() *AgentStatus { + if in == nil { + return nil + } + out := new(AgentStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InferenceConfigurationInitParameters) DeepCopyInto(out *InferenceConfigurationInitParameters) { + *out = *in + if in.MaxLength != nil { + in, out := &in.MaxLength, &out.MaxLength + *out = new(float64) + **out = **in + } + if in.StopSequences != nil { + in, out := &in.StopSequences, &out.StopSequences + *out = make([]*string, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(string) + **out = **in + } + } + } + if in.Temperature != nil { + in, out := &in.Temperature, &out.Temperature + *out = new(float64) + **out = **in + } + if in.TopK != nil { + in, out := &in.TopK, &out.TopK + *out = new(float64) + **out = **in + } + if in.TopP != nil { + in, out := &in.TopP, &out.TopP + *out = new(float64) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InferenceConfigurationInitParameters. +func (in *InferenceConfigurationInitParameters) DeepCopy() *InferenceConfigurationInitParameters { + if in == nil { + return nil + } + out := new(InferenceConfigurationInitParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InferenceConfigurationObservation) DeepCopyInto(out *InferenceConfigurationObservation) { + *out = *in + if in.MaxLength != nil { + in, out := &in.MaxLength, &out.MaxLength + *out = new(float64) + **out = **in + } + if in.StopSequences != nil { + in, out := &in.StopSequences, &out.StopSequences + *out = make([]*string, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(string) + **out = **in + } + } + } + if in.Temperature != nil { + in, out := &in.Temperature, &out.Temperature + *out = new(float64) + **out = **in + } + if in.TopK != nil { + in, out := &in.TopK, &out.TopK + *out = new(float64) + **out = **in + } + if in.TopP != nil { + in, out := &in.TopP, &out.TopP + *out = new(float64) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InferenceConfigurationObservation. +func (in *InferenceConfigurationObservation) DeepCopy() *InferenceConfigurationObservation { + if in == nil { + return nil + } + out := new(InferenceConfigurationObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InferenceConfigurationParameters) DeepCopyInto(out *InferenceConfigurationParameters) { + *out = *in + if in.MaxLength != nil { + in, out := &in.MaxLength, &out.MaxLength + *out = new(float64) + **out = **in + } + if in.StopSequences != nil { + in, out := &in.StopSequences, &out.StopSequences + *out = make([]*string, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(string) + **out = **in + } + } + } + if in.Temperature != nil { + in, out := &in.Temperature, &out.Temperature + *out = new(float64) + **out = **in + } + if in.TopK != nil { + in, out := &in.TopK, &out.TopK + *out = new(float64) + **out = **in + } + if in.TopP != nil { + in, out := &in.TopP, &out.TopP + *out = new(float64) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InferenceConfigurationParameters. +func (in *InferenceConfigurationParameters) DeepCopy() *InferenceConfigurationParameters { + if in == nil { + return nil + } + out := new(InferenceConfigurationParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PromptConfigurationsInitParameters) DeepCopyInto(out *PromptConfigurationsInitParameters) { + *out = *in + if in.BasePromptTemplate != nil { + in, out := &in.BasePromptTemplate, &out.BasePromptTemplate + *out = new(string) + **out = **in + } + if in.InferenceConfiguration != nil { + in, out := &in.InferenceConfiguration, &out.InferenceConfiguration + *out = make([]InferenceConfigurationInitParameters, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ParserMode != nil { + in, out := &in.ParserMode, &out.ParserMode + *out = new(string) + **out = **in + } + if in.PromptCreationMode != nil { + in, out := &in.PromptCreationMode, &out.PromptCreationMode + *out = new(string) + **out = **in + } + if in.PromptState != nil { + in, out := &in.PromptState, &out.PromptState + *out = new(string) + **out = **in + } + if in.PromptType != nil { + in, out := &in.PromptType, &out.PromptType + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PromptConfigurationsInitParameters. +func (in *PromptConfigurationsInitParameters) DeepCopy() *PromptConfigurationsInitParameters { + if in == nil { + return nil + } + out := new(PromptConfigurationsInitParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PromptConfigurationsObservation) DeepCopyInto(out *PromptConfigurationsObservation) { + *out = *in + if in.BasePromptTemplate != nil { + in, out := &in.BasePromptTemplate, &out.BasePromptTemplate + *out = new(string) + **out = **in + } + if in.InferenceConfiguration != nil { + in, out := &in.InferenceConfiguration, &out.InferenceConfiguration + *out = make([]InferenceConfigurationObservation, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ParserMode != nil { + in, out := &in.ParserMode, &out.ParserMode + *out = new(string) + **out = **in + } + if in.PromptCreationMode != nil { + in, out := &in.PromptCreationMode, &out.PromptCreationMode + *out = new(string) + **out = **in + } + if in.PromptState != nil { + in, out := &in.PromptState, &out.PromptState + *out = new(string) + **out = **in + } + if in.PromptType != nil { + in, out := &in.PromptType, &out.PromptType + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PromptConfigurationsObservation. +func (in *PromptConfigurationsObservation) DeepCopy() *PromptConfigurationsObservation { + if in == nil { + return nil + } + out := new(PromptConfigurationsObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PromptConfigurationsParameters) DeepCopyInto(out *PromptConfigurationsParameters) { + *out = *in + if in.BasePromptTemplate != nil { + in, out := &in.BasePromptTemplate, &out.BasePromptTemplate + *out = new(string) + **out = **in + } + if in.InferenceConfiguration != nil { + in, out := &in.InferenceConfiguration, &out.InferenceConfiguration + *out = make([]InferenceConfigurationParameters, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ParserMode != nil { + in, out := &in.ParserMode, &out.ParserMode + *out = new(string) + **out = **in + } + if in.PromptCreationMode != nil { + in, out := &in.PromptCreationMode, &out.PromptCreationMode + *out = new(string) + **out = **in + } + if in.PromptState != nil { + in, out := &in.PromptState, &out.PromptState + *out = new(string) + **out = **in + } + if in.PromptType != nil { + in, out := &in.PromptType, &out.PromptType + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PromptConfigurationsParameters. +func (in *PromptConfigurationsParameters) DeepCopy() *PromptConfigurationsParameters { + if in == nil { + return nil + } + out := new(PromptConfigurationsParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PromptOverrideConfigurationInitParameters) DeepCopyInto(out *PromptOverrideConfigurationInitParameters) { + *out = *in + if in.OverrideLambda != nil { + in, out := &in.OverrideLambda, &out.OverrideLambda + *out = new(string) + **out = **in + } + if in.PromptConfigurations != nil { + in, out := &in.PromptConfigurations, &out.PromptConfigurations + *out = make([]PromptConfigurationsInitParameters, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PromptOverrideConfigurationInitParameters. +func (in *PromptOverrideConfigurationInitParameters) DeepCopy() *PromptOverrideConfigurationInitParameters { + if in == nil { + return nil + } + out := new(PromptOverrideConfigurationInitParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PromptOverrideConfigurationObservation) DeepCopyInto(out *PromptOverrideConfigurationObservation) { + *out = *in + if in.OverrideLambda != nil { + in, out := &in.OverrideLambda, &out.OverrideLambda + *out = new(string) + **out = **in + } + if in.PromptConfigurations != nil { + in, out := &in.PromptConfigurations, &out.PromptConfigurations + *out = make([]PromptConfigurationsObservation, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PromptOverrideConfigurationObservation. +func (in *PromptOverrideConfigurationObservation) DeepCopy() *PromptOverrideConfigurationObservation { + if in == nil { + return nil + } + out := new(PromptOverrideConfigurationObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PromptOverrideConfigurationParameters) DeepCopyInto(out *PromptOverrideConfigurationParameters) { + *out = *in + if in.OverrideLambda != nil { + in, out := &in.OverrideLambda, &out.OverrideLambda + *out = new(string) + **out = **in + } + if in.PromptConfigurations != nil { + in, out := &in.PromptConfigurations, &out.PromptConfigurations + *out = make([]PromptConfigurationsParameters, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PromptOverrideConfigurationParameters. +func (in *PromptOverrideConfigurationParameters) DeepCopy() *PromptOverrideConfigurationParameters { + if in == nil { + return nil + } + out := new(PromptOverrideConfigurationParameters) + in.DeepCopyInto(out) + return out +} diff --git a/apis/bedrockagent/v1beta1/zz_generated.managed.go b/apis/bedrockagent/v1beta1/zz_generated.managed.go new file mode 100644 index 0000000000..448a68788a --- /dev/null +++ b/apis/bedrockagent/v1beta1/zz_generated.managed.go @@ -0,0 +1,68 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 +// Code generated by angryjet. DO NOT EDIT. + +package v1beta1 + +import xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + +// GetCondition of this Agent. +func (mg *Agent) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return mg.Status.GetCondition(ct) +} + +// GetDeletionPolicy of this Agent. +func (mg *Agent) GetDeletionPolicy() xpv1.DeletionPolicy { + return mg.Spec.DeletionPolicy +} + +// GetManagementPolicies of this Agent. +func (mg *Agent) GetManagementPolicies() xpv1.ManagementPolicies { + return mg.Spec.ManagementPolicies +} + +// GetProviderConfigReference of this Agent. +func (mg *Agent) GetProviderConfigReference() *xpv1.Reference { + return mg.Spec.ProviderConfigReference +} + +// GetPublishConnectionDetailsTo of this Agent. +func (mg *Agent) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { + return mg.Spec.PublishConnectionDetailsTo +} + +// GetWriteConnectionSecretToReference of this Agent. +func (mg *Agent) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + return mg.Spec.WriteConnectionSecretToReference +} + +// SetConditions of this Agent. +func (mg *Agent) SetConditions(c ...xpv1.Condition) { + mg.Status.SetConditions(c...) +} + +// SetDeletionPolicy of this Agent. +func (mg *Agent) SetDeletionPolicy(r xpv1.DeletionPolicy) { + mg.Spec.DeletionPolicy = r +} + +// SetManagementPolicies of this Agent. +func (mg *Agent) SetManagementPolicies(r xpv1.ManagementPolicies) { + mg.Spec.ManagementPolicies = r +} + +// SetProviderConfigReference of this Agent. +func (mg *Agent) SetProviderConfigReference(r *xpv1.Reference) { + mg.Spec.ProviderConfigReference = r +} + +// SetPublishConnectionDetailsTo of this Agent. +func (mg *Agent) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { + mg.Spec.PublishConnectionDetailsTo = r +} + +// SetWriteConnectionSecretToReference of this Agent. +func (mg *Agent) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { + mg.Spec.WriteConnectionSecretToReference = r +} diff --git a/apis/bedrockagent/v1beta1/zz_generated.managedlist.go b/apis/bedrockagent/v1beta1/zz_generated.managedlist.go new file mode 100644 index 0000000000..a75a18e9de --- /dev/null +++ b/apis/bedrockagent/v1beta1/zz_generated.managedlist.go @@ -0,0 +1,17 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 +// Code generated by angryjet. DO NOT EDIT. + +package v1beta1 + +import resource "github.com/crossplane/crossplane-runtime/pkg/resource" + +// GetItems of this AgentList. +func (l *AgentList) GetItems() []resource.Managed { + items := make([]resource.Managed, len(l.Items)) + for i := range l.Items { + items[i] = &l.Items[i] + } + return items +} diff --git a/apis/bedrockagent/v1beta1/zz_generated.resolvers.go b/apis/bedrockagent/v1beta1/zz_generated.resolvers.go new file mode 100644 index 0000000000..08b01a086f --- /dev/null +++ b/apis/bedrockagent/v1beta1/zz_generated.resolvers.go @@ -0,0 +1,69 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 +// Code generated by angryjet. DO NOT EDIT. +// Code transformed by upjet. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + reference "github.com/crossplane/crossplane-runtime/pkg/reference" + errors "github.com/pkg/errors" + + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + common "github.com/upbound/provider-aws/config/common" + client "sigs.k8s.io/controller-runtime/pkg/client" + + // ResolveReferences of this Agent. + apisresolver "github.com/upbound/provider-aws/internal/apis" +) + +func (mg *Agent) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList + r := reference.NewAPIResolver(c, mg) + + var rsp reference.ResolutionResponse + var err error + { + m, l, err = apisresolver.GetManagedResource("iam.aws.upbound.io", "v1beta1", "Role", "RoleList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.AgentResourceRoleArn), + Extract: common.ARNExtractor(), + Reference: mg.Spec.ForProvider.AgentResourceRoleArnRef, + Selector: mg.Spec.ForProvider.AgentResourceRoleArnSelector, + To: reference.To{List: l, Managed: m}, + }) + } + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.AgentResourceRoleArn") + } + mg.Spec.ForProvider.AgentResourceRoleArn = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.AgentResourceRoleArnRef = rsp.ResolvedReference + { + m, l, err = apisresolver.GetManagedResource("iam.aws.upbound.io", "v1beta1", "Role", "RoleList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.AgentResourceRoleArn), + Extract: common.ARNExtractor(), + Reference: mg.Spec.InitProvider.AgentResourceRoleArnRef, + Selector: mg.Spec.InitProvider.AgentResourceRoleArnSelector, + To: reference.To{List: l, Managed: m}, + }) + } + if err != nil { + return errors.Wrap(err, "mg.Spec.InitProvider.AgentResourceRoleArn") + } + mg.Spec.InitProvider.AgentResourceRoleArn = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.InitProvider.AgentResourceRoleArnRef = rsp.ResolvedReference + + return nil +} diff --git a/apis/bedrockagent/v1beta1/zz_groupversion_info.go b/apis/bedrockagent/v1beta1/zz_groupversion_info.go new file mode 100755 index 0000000000..7ebac3199b --- /dev/null +++ b/apis/bedrockagent/v1beta1/zz_groupversion_info.go @@ -0,0 +1,32 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by upjet. DO NOT EDIT. + +// +kubebuilder:object:generate=true +// +groupName=bedrockagent.aws.upbound.io +// +versionName=v1beta1 +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +// Package type metadata. +const ( + CRDGroup = "bedrockagent.aws.upbound.io" + CRDVersion = "v1beta1" +) + +var ( + // CRDGroupVersion is the API Group Version used to register the objects + CRDGroupVersion = schema.GroupVersion{Group: CRDGroup, Version: CRDVersion} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: CRDGroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/apis/zz_register.go b/apis/zz_register.go index 8088402d5e..eeac992e65 100755 --- a/apis/zz_register.go +++ b/apis/zz_register.go @@ -52,6 +52,7 @@ import ( v1beta2backup "github.com/upbound/provider-aws/apis/backup/v1beta2" v1beta1batch "github.com/upbound/provider-aws/apis/batch/v1beta1" v1beta2batch "github.com/upbound/provider-aws/apis/batch/v1beta2" + v1beta1bedrockagent "github.com/upbound/provider-aws/apis/bedrockagent/v1beta1" v1beta1budgets "github.com/upbound/provider-aws/apis/budgets/v1beta1" v1beta2budgets "github.com/upbound/provider-aws/apis/budgets/v1beta2" v1beta1ce "github.com/upbound/provider-aws/apis/ce/v1beta1" @@ -348,6 +349,7 @@ func init() { v1beta2backup.SchemeBuilder.AddToScheme, v1beta1batch.SchemeBuilder.AddToScheme, v1beta2batch.SchemeBuilder.AddToScheme, + v1beta1bedrockagent.SchemeBuilder.AddToScheme, v1beta1budgets.SchemeBuilder.AddToScheme, v1beta2budgets.SchemeBuilder.AddToScheme, v1beta1ce.SchemeBuilder.AddToScheme, diff --git a/cmd/provider/bedrockagent/zz_main.go b/cmd/provider/bedrockagent/zz_main.go new file mode 100644 index 0000000000..dba1ac7b2b --- /dev/null +++ b/cmd/provider/bedrockagent/zz_main.go @@ -0,0 +1,223 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +package main + +import ( + "context" + "fmt" + "io" + "log" + "os" + "path/filepath" + "time" + + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + "github.com/crossplane/crossplane-runtime/pkg/certificates" + xpcontroller "github.com/crossplane/crossplane-runtime/pkg/controller" + "github.com/crossplane/crossplane-runtime/pkg/feature" + "github.com/crossplane/crossplane-runtime/pkg/logging" + "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" + tjcontroller "github.com/crossplane/upjet/pkg/controller" + "github.com/crossplane/upjet/pkg/controller/conversion" + "gopkg.in/alecthomas/kingpin.v2" + kerrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/tools/leaderelection/resourcelock" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/cache" + "sigs.k8s.io/controller-runtime/pkg/log/zap" + "sigs.k8s.io/controller-runtime/pkg/metrics" + "sigs.k8s.io/controller-runtime/pkg/webhook" + + "github.com/upbound/provider-aws/apis" + "github.com/upbound/provider-aws/apis/v1alpha1" + "github.com/upbound/provider-aws/config" + resolverapis "github.com/upbound/provider-aws/internal/apis" + "github.com/upbound/provider-aws/internal/clients" + "github.com/upbound/provider-aws/internal/controller" + "github.com/upbound/provider-aws/internal/features" +) + +const ( + webhookTLSCertDirEnvVar = "WEBHOOK_TLS_CERT_DIR" + tlsServerCertDirEnvVar = "TLS_SERVER_CERTS_DIR" + certsDirEnvVar = "CERTS_DIR" + tlsServerCertDir = "/tls/server" +) + +func deprecationAction(flagName string) kingpin.Action { + return func(c *kingpin.ParseContext) error { + _, err := fmt.Fprintf(os.Stderr, "warning: Command-line flag %q is deprecated and no longer used. It will be removed in a future release. Please remove it from all of your configurations (ControllerConfigs, etc.).\n", flagName) + kingpin.FatalIfError(err, "Failed to print the deprecation notice.") + return nil + } +} + +func main() { + var ( + app = kingpin.New(filepath.Base(os.Args[0]), "AWS support for Crossplane.").DefaultEnvars() + debug = app.Flag("debug", "Run with debug logging.").Short('d').Bool() + syncInterval = app.Flag("sync", "Sync interval controls how often all resources will be double checked for drift.").Short('s').Default("1h").Duration() + pollInterval = app.Flag("poll", "Poll interval controls how often an individual resource should be checked for drift.").Default("10m").Duration() + pollStateMetricInterval = app.Flag("poll-state-metric", "State metric recording interval").Default("5s").Duration() + leaderElection = app.Flag("leader-election", "Use leader election for the controller manager.").Short('l').Default("false").OverrideDefaultFromEnvar("LEADER_ELECTION").Bool() + maxReconcileRate = app.Flag("max-reconcile-rate", "The global maximum rate per second at which resources may be checked for drift from the desired state.").Default("100").Int() + + namespace = app.Flag("namespace", "Namespace used to set as default scope in default secret store config.").Default("crossplane-system").Envar("POD_NAMESPACE").String() + enableExternalSecretStores = app.Flag("enable-external-secret-stores", "Enable support for ExternalSecretStores.").Default("false").Envar("ENABLE_EXTERNAL_SECRET_STORES").Bool() + essTLSCertsPath = app.Flag("ess-tls-cert-dir", "Path of ESS TLS certificates.").Envar("ESS_TLS_CERTS_DIR").String() + enableManagementPolicies = app.Flag("enable-management-policies", "Enable support for Management Policies.").Default("true").Envar("ENABLE_MANAGEMENT_POLICIES").Bool() + + certsDirSet = false + // we record whether the command-line option "--certs-dir" was supplied + // in the registered PreAction for the flag. + certsDir = app.Flag("certs-dir", "The directory that contains the server key and certificate.").Default(tlsServerCertDir).Envar(certsDirEnvVar).PreAction(func(_ *kingpin.ParseContext) error { + certsDirSet = true + return nil + }).String() + + // now deprecated command-line arguments with the Terraform SDK-based upjet architecture + _ = app.Flag("provider-ttl", "[DEPRECATED: This option is no longer used and it will be removed in a future release.] TTL for the native plugin processes before they are replaced. Changing the default may increase memory consumption.").Hidden().Action(deprecationAction("provider-ttl")).Int() + _ = app.Flag("terraform-version", "[DEPRECATED: This option is no longer used and it will be removed in a future release.] Terraform version.").Envar("TERRAFORM_VERSION").Hidden().Action(deprecationAction("terraform-version")).String() + _ = app.Flag("terraform-provider-version", "[DEPRECATED: This option is no longer used and it will be removed in a future release.] Terraform provider version.").Envar("TERRAFORM_PROVIDER_VERSION").Hidden().Action(deprecationAction("terraform-provider-version")).String() + _ = app.Flag("terraform-native-provider-path", "[DEPRECATED: This option is no longer used and it will be removed in a future release.] Terraform native provider path for shared execution.").Envar("TERRAFORM_NATIVE_PROVIDER_PATH").Hidden().Action(deprecationAction("terraform-native-provider-path")).String() + _ = app.Flag("terraform-provider-source", "[DEPRECATED: This option is no longer used and it will be removed in a future release.] Terraform provider source.").Envar("TERRAFORM_PROVIDER_SOURCE").Hidden().Action(deprecationAction("terraform-provider-source")).String() + ) + kingpin.MustParse(app.Parse(os.Args[1:])) + log.Default().SetOutput(io.Discard) + ctrl.SetLogger(zap.New(zap.WriteTo(io.Discard))) + + zl := zap.New(zap.UseDevMode(*debug)) + logr := logging.NewLogrLogger(zl.WithName("provider-aws")) + if *debug { + // The controller-runtime runs with a no-op logger by default. It is + // *very* verbose even at info level, so we only provide it a real + // logger when we're running in debug mode. + ctrl.SetLogger(zl) + } + + // currently, we configure the jitter to be the 5% of the poll interval + pollJitter := time.Duration(float64(*pollInterval) * 0.05) + logr.Debug("Starting", "sync-interval", syncInterval.String(), + "poll-interval", pollInterval.String(), "poll-jitter", pollJitter, "max-reconcile-rate", *maxReconcileRate) + + cfg, err := ctrl.GetConfig() + kingpin.FatalIfError(err, "Cannot get API server rest config") + + // Get the TLS certs directory from the environment variables set by + // Crossplane if they're available. + // In older XP versions we used WEBHOOK_TLS_CERT_DIR, in newer versions + // we use TLS_SERVER_CERTS_DIR. If an explicit certs dir is not supplied + // via the command-line options, then these environment variables are used + // instead. + if !certsDirSet { + // backwards-compatibility concerns + xpCertsDir := os.Getenv(certsDirEnvVar) + if xpCertsDir == "" { + xpCertsDir = os.Getenv(tlsServerCertDirEnvVar) + } + if xpCertsDir == "" { + xpCertsDir = os.Getenv(webhookTLSCertDirEnvVar) + } + // we probably don't need this condition but just to be on the + // safe side, if we are missing any kingpin machinery details... + if xpCertsDir != "" { + *certsDir = xpCertsDir + } + } + + mgr, err := ctrl.NewManager(ratelimiter.LimitRESTConfig(cfg, *maxReconcileRate), ctrl.Options{ + LeaderElection: *leaderElection, + LeaderElectionID: "crossplane-leader-election-provider-aws-bedrockagent", + Cache: cache.Options{ + SyncPeriod: syncInterval, + }, + WebhookServer: webhook.NewServer( + webhook.Options{ + CertDir: *certsDir, + }), + LeaderElectionResourceLock: resourcelock.LeasesResourceLock, + LeaseDuration: func() *time.Duration { d := 60 * time.Second; return &d }(), + RenewDeadline: func() *time.Duration { d := 50 * time.Second; return &d }(), + }) + kingpin.FatalIfError(err, "Cannot create controller manager") + kingpin.FatalIfError(apis.AddToScheme(mgr.GetScheme()), "Cannot add AWS APIs to scheme") + kingpin.FatalIfError(resolverapis.BuildScheme(apis.AddToSchemes), "Cannot register the AWS APIs with the API resolver's runtime scheme") + + metricRecorder := managed.NewMRMetricRecorder() + stateMetrics := statemetrics.NewMRStateMetrics() + + metrics.Registry.MustRegister(metricRecorder) + metrics.Registry.MustRegister(stateMetrics) + + ctx := context.Background() + provider, err := config.GetProvider(ctx, false) + kingpin.FatalIfError(err, "Cannot initialize the provider configuration") + setupConfig := &clients.SetupConfig{ + Logger: logr, + TerraformProvider: provider.TerraformProvider, + } + o := tjcontroller.Options{ + Options: xpcontroller.Options{ + Logger: logr, + GlobalRateLimiter: ratelimiter.NewGlobal(*maxReconcileRate), + PollInterval: *pollInterval, + MaxConcurrentReconciles: *maxReconcileRate, + Features: &feature.Flags{}, + MetricOptions: &xpcontroller.MetricOptions{ + PollStateMetricInterval: *pollStateMetricInterval, + MRMetrics: metricRecorder, + MRStateMetrics: stateMetrics, + }, + }, + Provider: provider, + SetupFn: clients.SelectTerraformSetup(setupConfig), + PollJitter: pollJitter, + OperationTrackerStore: tjcontroller.NewOperationStore(logr), + StartWebhooks: *certsDir != "", + } + + if *enableManagementPolicies { + o.Features.Enable(features.EnableBetaManagementPolicies) + logr.Info("Beta feature enabled", "flag", features.EnableBetaManagementPolicies) + } + + if *enableExternalSecretStores { + o.SecretStoreConfigGVK = &v1alpha1.StoreConfigGroupVersionKind + logr.Info("Alpha feature enabled", "flag", features.EnableAlphaExternalSecretStores) + + o.ESSOptions = &tjcontroller.ESSOptions{} + if *essTLSCertsPath != "" { + logr.Info("ESS TLS certificates path is set. Loading mTLS configuration.") + tCfg, err := certificates.LoadMTLSConfig(filepath.Join(*essTLSCertsPath, "ca.crt"), filepath.Join(*essTLSCertsPath, "tls.crt"), filepath.Join(*essTLSCertsPath, "tls.key"), false) + kingpin.FatalIfError(err, "Cannot load ESS TLS config.") + + o.ESSOptions.TLSConfig = tCfg + } + + // Ensure default store config exists. + kingpin.FatalIfError(resource.Ignore(kerrors.IsAlreadyExists, mgr.GetClient().Create(ctx, &v1alpha1.StoreConfig{ + TypeMeta: metav1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{ + Name: "default", + }, + Spec: v1alpha1.StoreConfigSpec{ + // NOTE(turkenh): We only set required spec and expect optional + // ones to properly be initialized with CRD level default values. + SecretStoreConfig: xpv1.SecretStoreConfig{ + DefaultScope: *namespace, + }, + }, + Status: v1alpha1.StoreConfigStatus{}, + })), "cannot create default store config") + } + + kingpin.FatalIfError(conversion.RegisterConversions(o.Provider), "Cannot initialize the webhook conversion registry") + kingpin.FatalIfError(controller.Setup_bedrockagent(mgr, o), "Cannot setup AWS controllers") + kingpin.FatalIfError(mgr.Start(ctrl.SetupSignalHandler()), "Cannot start controller manager") +} diff --git a/config/bedrockagent/config.go b/config/bedrockagent/config.go new file mode 100644 index 0000000000..d115b3252e --- /dev/null +++ b/config/bedrockagent/config.go @@ -0,0 +1,24 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: CC0-1.0 + +package backup + +import ( + "github.com/crossplane/upjet/pkg/config" + + "github.com/upbound/provider-aws/config/common" +) + +func Configure(p *config.Provider) { + p.AddResourceConfigurator("aws_bedrockagent_agent", func(r *config.Resource) { + r.References["customer_encryption_key_arn"] = config.Reference{ + TerraformName: "aws_kms_key", + Extractor: common.PathARNExtractor, + } + r.References["agent_resource_role_arn"] = config.Reference{ + TerraformName: "aws_iam_role", + Extractor: common.PathARNExtractor, + } + }) +} diff --git a/config/externalname.go b/config/externalname.go index a30c535ab9..7a7a77d8d2 100644 --- a/config/externalname.go +++ b/config/externalname.go @@ -29,6 +29,11 @@ var TerraformPluginFrameworkExternalNameConfigs = map[string]config.ExternalName // terraform-plugin-framework "aws_appconfig_environment": appConfigEnvironment(), + // bedrockagent + // + // Bedrock Agent can be imported using the agent arn + "aws_bedrockagent_agent": bedrockAgent(), + // CodeGuru Profiler // Profiling Group can be imported using the the profiling group name "aws_codeguruprofiler_profiling_group": config.NameAsIdentifier, @@ -2864,6 +2869,19 @@ func kmsAlias() config.ExternalName { return e } +func bedrockAgent() config.ExternalName { + // Terraform does not allow agent id to be empty. + // Using a stub value to pass validation. + e := config.IdentifierFromProvider + e.GetIDFn = func(_ context.Context, externalName string, _ map[string]any, _ map[string]any) (string, error) { + if len(externalName) == 0 { + return "STUB123456", nil + } + return externalName, nil + } + return e +} + func vpcSecurityGroupRule() config.ExternalName { // Terraform does not allow security group rule id to be empty. // Using a stub value to pass validation. diff --git a/config/generated.lst b/config/generated.lst index 7e5c0a5cd6..4ac2a62233 100644 --- a/config/generated.lst +++ b/config/generated.lst @@ -117,6 +117,7 @@ "aws_backup_vault_policy", "aws_batch_job_definition", "aws_batch_scheduling_policy", +"aws_bedrockagent_agent", "aws_budgets_budget", "aws_budgets_budget_action", "aws_ce_anomaly_monitor", diff --git a/examples-generated/bedrockagent/v1beta1/agent.yaml b/examples-generated/bedrockagent/v1beta1/agent.yaml new file mode 100644 index 0000000000..a70bad9ba1 --- /dev/null +++ b/examples-generated/bedrockagent/v1beta1/agent.yaml @@ -0,0 +1,48 @@ +apiVersion: bedrockagent.aws.upbound.io/v1beta1 +kind: Agent +metadata: + annotations: + meta.upbound.io/example-id: bedrockagent/v1beta1/agent + labels: + testing.upbound.io/example-name: example + name: example +spec: + forProvider: + agentName: my-agent-name + agentResourceRoleArnSelector: + matchLabels: + testing.upbound.io/example-name: example + foundationModel: anthropic.claude-v2 + idleSessionTtlInSeconds: 500 + region: us-west-1 + +--- + +apiVersion: iam.aws.upbound.io/v1beta1 +kind: Role +metadata: + annotations: + meta.upbound.io/example-id: bedrockagent/v1beta1/agent + labels: + testing.upbound.io/example-name: example + name: example +spec: + forProvider: + assumeRolePolicy: ${data.aws_iam_policy_document.example_agent_trust.json} + +--- + +apiVersion: iam.aws.upbound.io/v1beta1 +kind: RolePolicy +metadata: + annotations: + meta.upbound.io/example-id: bedrockagent/v1beta1/agent + labels: + testing.upbound.io/example-name: example + name: example +spec: + forProvider: + policy: ${data.aws_iam_policy_document.example_agent_permissions.json} + roleSelector: + matchLabels: + testing.upbound.io/example-name: example diff --git a/examples/bedrockagent/v1beta1/agent.yaml b/examples/bedrockagent/v1beta1/agent.yaml new file mode 100644 index 0000000000..81ba119463 --- /dev/null +++ b/examples/bedrockagent/v1beta1/agent.yaml @@ -0,0 +1,75 @@ +apiVersion: bedrockagent.aws.upbound.io/v1beta1 +kind: Agent +metadata: + annotations: + meta.upbound.io/example-id: bedrockagent/v1beta1/agent + labels: + testing.upbound.io/example-name: example-bedrockagent-model + name: example +spec: + forProvider: + agentName: example + instruction: an example instruction that is required to pass + agentResourceRoleArnSelector: + matchLabels: + testing.upbound.io/example-name: example-bedrockagent-model + foundationModel: anthropic.claude-v2 + idleSessionTtlInSeconds: 500 + region: us-east-1 + +--- + +apiVersion: iam.aws.upbound.io/v1beta1 +kind: Role +metadata: + annotations: + meta.upbound.io/example-id: bedrockagent/v1beta1/agent + labels: + testing.upbound.io/example-name: example-bedrockagent-model + name: example-bedrockagent-model +spec: + forProvider: + assumeRolePolicy: | + { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Principal": { + "Service": "bedrock.amazonaws.com" + }, + "Action": "sts:AssumeRole" + } + ] + } + region: us-east-1 + +--- + +apiVersion: iam.aws.upbound.io/v1beta1 +kind: RolePolicy +metadata: + annotations: + meta.upbound.io/example-id: bedrockagent/v1beta1/agent + labels: + testing.upbound.io/example-name: example-bedrockagent-model + name: example-bedrockagent-model +spec: + forProvider: + policy: | + { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "bedrock:InvokeModel" + ], + "Resource": "*" + } + ] + } + roleSelector: + matchLabels: + testing.upbound.io/example-name: example-bedrockagent-model + region: us-east-1 diff --git a/internal/controller/bedrockagent/agent/zz_controller.go b/internal/controller/bedrockagent/agent/zz_controller.go new file mode 100755 index 0000000000..a9e57805bc --- /dev/null +++ b/internal/controller/bedrockagent/agent/zz_controller.go @@ -0,0 +1,94 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by upjet. DO NOT EDIT. + +package agent + +import ( + "time" + + "github.com/crossplane/crossplane-runtime/pkg/connection" + "github.com/crossplane/crossplane-runtime/pkg/event" + "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" + tjcontroller "github.com/crossplane/upjet/pkg/controller" + "github.com/crossplane/upjet/pkg/controller/handler" + "github.com/crossplane/upjet/pkg/metrics" + "github.com/pkg/errors" + ctrl "sigs.k8s.io/controller-runtime" + + v1beta1 "github.com/upbound/provider-aws/apis/bedrockagent/v1beta1" + features "github.com/upbound/provider-aws/internal/features" +) + +// Setup adds a controller that reconciles Agent managed resources. +func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { + name := managed.ControllerName(v1beta1.Agent_GroupVersionKind.String()) + var initializers managed.InitializerChain + for _, i := range o.Provider.Resources["aws_bedrockagent_agent"].InitializerFns { + initializers = append(initializers, i(mgr.GetClient())) + } + cps := []managed.ConnectionPublisher{managed.NewAPISecretPublisher(mgr.GetClient(), mgr.GetScheme())} + if o.SecretStoreConfigGVK != nil { + cps = append(cps, connection.NewDetailsManager(mgr.GetClient(), *o.SecretStoreConfigGVK, connection.WithTLSConfig(o.ESSOptions.TLSConfig))) + } + eventHandler := handler.NewEventHandler(handler.WithLogger(o.Logger.WithValues("gvk", v1beta1.Agent_GroupVersionKind))) + ac := tjcontroller.NewAPICallbacks(mgr, xpresource.ManagedKind(v1beta1.Agent_GroupVersionKind), tjcontroller.WithEventHandler(eventHandler), tjcontroller.WithStatusUpdates(false)) + opts := []managed.ReconcilerOption{ + managed.WithExternalConnecter( + tjcontroller.NewTerraformPluginFrameworkAsyncConnector(mgr.GetClient(), o.OperationTrackerStore, o.SetupFn, o.Provider.Resources["aws_bedrockagent_agent"], + tjcontroller.WithTerraformPluginFrameworkAsyncLogger(o.Logger), + tjcontroller.WithTerraformPluginFrameworkAsyncConnectorEventHandler(eventHandler), + tjcontroller.WithTerraformPluginFrameworkAsyncCallbackProvider(ac), + tjcontroller.WithTerraformPluginFrameworkAsyncMetricRecorder(metrics.NewMetricRecorder(v1beta1.Agent_GroupVersionKind, mgr, o.PollInterval)), + tjcontroller.WithTerraformPluginFrameworkAsyncManagementPolicies(o.Features.Enabled(features.EnableBetaManagementPolicies)))), + managed.WithLogger(o.Logger.WithValues("controller", name)), + managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))), + managed.WithFinalizer(tjcontroller.NewOperationTrackerFinalizer(o.OperationTrackerStore, xpresource.NewAPIFinalizer(mgr.GetClient(), managed.FinalizerName))), + managed.WithTimeout(3 * time.Minute), + managed.WithInitializers(initializers), + managed.WithConnectionPublishers(cps...), + managed.WithPollInterval(o.PollInterval), + } + if o.PollJitter != 0 { + opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) + } + if o.Features.Enabled(features.EnableBetaManagementPolicies) { + opts = append(opts, managed.WithManagementPolicies()) + } + if o.MetricOptions != nil { + opts = append(opts, managed.WithMetricRecorder(o.MetricOptions.MRMetrics)) + } + + // register webhooks for the kind v1beta1.Agent + // if they're enabled. + if o.StartWebhooks { + if err := ctrl.NewWebhookManagedBy(mgr). + For(&v1beta1.Agent{}). + Complete(); err != nil { + return errors.Wrap(err, "cannot register webhook for the kind v1beta1.Agent") + } + } + + if o.MetricOptions != nil && o.MetricOptions.MRStateMetrics != nil { + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.AgentList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return errors.Wrap(err, "cannot register MR state metrics recorder for kind v1beta1.AgentList") + } + } + + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.Agent_GroupVersionKind), opts...) + + return ctrl.NewControllerManagedBy(mgr). + Named(name). + WithOptions(o.ForControllerRuntime()). + WithEventFilter(xpresource.DesiredStateChanged()). + Watches(&v1beta1.Agent{}, eventHandler). + Complete(ratelimiter.NewReconciler(name, r, o.GlobalRateLimiter)) +} diff --git a/internal/controller/zz_bedrockagent_setup.go b/internal/controller/zz_bedrockagent_setup.go new file mode 100755 index 0000000000..f8a689a8f5 --- /dev/null +++ b/internal/controller/zz_bedrockagent_setup.go @@ -0,0 +1,26 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +package controller + +import ( + ctrl "sigs.k8s.io/controller-runtime" + + "github.com/crossplane/upjet/pkg/controller" + + agent "github.com/upbound/provider-aws/internal/controller/bedrockagent/agent" +) + +// Setup_bedrockagent creates all controllers with the supplied logger and adds them to +// the supplied manager. +func Setup_bedrockagent(mgr ctrl.Manager, o controller.Options) error { + for _, setup := range []func(ctrl.Manager, controller.Options) error{ + agent.Setup, + } { + if err := setup(mgr, o); err != nil { + return err + } + } + return nil +} diff --git a/internal/controller/zz_monolith_setup.go b/internal/controller/zz_monolith_setup.go index 6a7f89eb5f..8c2cdc5fce 100755 --- a/internal/controller/zz_monolith_setup.go +++ b/internal/controller/zz_monolith_setup.go @@ -127,6 +127,7 @@ import ( vaultpolicy "github.com/upbound/provider-aws/internal/controller/backup/vaultpolicy" jobdefinition "github.com/upbound/provider-aws/internal/controller/batch/jobdefinition" schedulingpolicy "github.com/upbound/provider-aws/internal/controller/batch/schedulingpolicy" + agent "github.com/upbound/provider-aws/internal/controller/bedrockagent/agent" budget "github.com/upbound/provider-aws/internal/controller/budgets/budget" budgetaction "github.com/upbound/provider-aws/internal/controller/budgets/budgetaction" anomalymonitor "github.com/upbound/provider-aws/internal/controller/ce/anomalymonitor" @@ -1089,6 +1090,7 @@ func Setup_monolith(mgr ctrl.Manager, o controller.Options) error { vaultpolicy.Setup, jobdefinition.Setup, schedulingpolicy.Setup, + agent.Setup, budget.Setup, budgetaction.Setup, anomalymonitor.Setup, diff --git a/package/crds/bedrockagent.aws.upbound.io_agents.yaml b/package/crds/bedrockagent.aws.upbound.io_agents.yaml new file mode 100644 index 0000000000..76e96a1f6c --- /dev/null +++ b/package/crds/bedrockagent.aws.upbound.io_agents.yaml @@ -0,0 +1,922 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.14.0 + name: agents.bedrockagent.aws.upbound.io +spec: + group: bedrockagent.aws.upbound.io + names: + categories: + - crossplane + - managed + - aws + kind: Agent + listKind: AgentList + plural: agents + singular: agent + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Synced')].status + name: SYNCED + type: string + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .metadata.annotations.crossplane\.io/external-name + name: EXTERNAL-NAME + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1beta1 + schema: + openAPIV3Schema: + description: Agent is the Schema for the Agents API. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: AgentSpec defines the desired state of Agent + properties: + deletionPolicy: + default: Delete + description: |- + DeletionPolicy specifies what will happen to the underlying external + when this managed resource is deleted - either "Delete" or "Orphan" the + external resource. + This field is planned to be deprecated in favor of the ManagementPolicies + field in a future release. Currently, both could be set independently and + non-default values would be honored if the feature flag is enabled. + See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + enum: + - Orphan + - Delete + type: string + forProvider: + properties: + agentName: + description: Name of the agent. + type: string + agentResourceRoleArn: + description: ARN of the IAM role with permissions to invoke API + operations on the agent. + type: string + agentResourceRoleArnRef: + description: Reference to a Role in iam to populate agentResourceRoleArn. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + agentResourceRoleArnSelector: + description: Selector for a Role in iam to populate agentResourceRoleArn. + properties: + matchControllerRef: + description: |- + MatchControllerRef ensures an object with the same controller reference + as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching labels + is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + customerEncryptionKeyArn: + description: ARN of the AWS KMS key that encrypts the agent. + type: string + description: + description: Description of the agent. + type: string + foundationModel: + description: Foundation model used for orchestration by the agent. + type: string + idleSessionTtlInSeconds: + description: Number of seconds for which Amazon Bedrock keeps + information about a user's conversation with the agent. A user + interaction remains active for the amount of time specified. + If no conversation occurs during this time, the session expires + and Amazon Bedrock deletes any data provided before the timeout. + type: number + instruction: + description: Instructions that tell the agent what it should do + and how it should interact with users. + type: string + prepareAgent: + description: Whether to prepare the agent after creation or modification. + Defaults to true. + type: boolean + promptOverrideConfiguration: + description: Configurations to override prompt templates in different + parts of an agent sequence. For more information, see Advanced + prompts. See prompt_override_configuration Block for details. + items: + properties: + overrideLambda: + description: ARN of the Lambda function to use when parsing + the raw foundation model output in parts of the agent + sequence. If you specify this field, at least one of the + prompt_configurations block must contain a parser_mode + value that is set to OVERRIDDEN. + type: string + promptConfigurations: + description: Configurations to override a prompt template + in one part of an agent sequence. See prompt_configurations + Block for details. + items: + properties: + basePromptTemplate: + description: prompt template with which to replace + the default prompt template. You can use placeholder + variables in the base prompt template to customize + the prompt. For more information, see Prompt template + placeholder variables. + type: string + inferenceConfiguration: + description: Inference parameters to use when the + agent invokes a foundation model in the part of + the agent sequence defined by the prompt_type. For + more information, see Inference parameters for foundation + models. See inference_configuration Block for details. + items: + properties: + maxLength: + description: Maximum number of tokens to allow + in the generated response. + type: number + stopSequences: + description: List of stop sequences. A stop + sequence is a sequence of characters that + causes the model to stop generating the response. + items: + type: string + type: array + temperature: + description: Likelihood of the model selecting + higher-probability options while generating + a response. A lower value makes the model + more likely to choose higher-probability options, + while a higher value makes the model more + likely to choose lower-probability options. + type: number + topK: + description: Number of top most-likely candidates, + between 0 and 500, from which the model chooses + the next token in the sequence. + type: number + topP: + description: Top percentage of the probability + distribution of next tokens, between 0 and + 1 (denoting 0% and 100%), from which the model + chooses the next token in the sequence. + type: number + type: object + type: array + parserMode: + description: 'Whether to override the default parser + Lambda function when parsing the raw foundation + model output in the part of the agent sequence defined + by the prompt_type. If you set the argument as OVERRIDDEN, + the override_lambda argument in the prompt_override_configuration + block must be specified with the ARN of a Lambda + function. Valid values: DEFAULT, OVERRIDDEN.' + type: string + promptCreationMode: + description: 'Whether to override the default prompt + template for this prompt_type. Set this argument + to OVERRIDDEN to use the prompt that you provide + in the base_prompt_template. If you leave it as + DEFAULT, the agent uses a default prompt template. + Valid values: DEFAULT, OVERRIDDEN.' + type: string + promptState: + description: 'Whether to allow the agent to carry + out the step specified in the prompt_type. If you + set this argument to DISABLED, the agent skips that + step. Valid Values: ENABLED, DISABLED.' + type: string + promptType: + description: 'Step in the agent sequence that this + prompt configuration applies to. Valid values: PRE_PROCESSING, + ORCHESTRATION, POST_PROCESSING, KNOWLEDGE_BASE_RESPONSE_GENERATION.' + type: string + type: object + type: array + type: object + type: array + region: + description: Region is the region you'd like your resource to + be created in. + type: string + skipResourceInUseCheck: + description: Whether the in-use check is skipped when deleting + the agent. + type: boolean + tags: + additionalProperties: + type: string + description: Key-value map of resource tags. + type: object + x-kubernetes-map-type: granular + required: + - region + type: object + initProvider: + description: |- + THIS IS A BETA FIELD. It will be honored + unless the Management Policies feature flag is disabled. + InitProvider holds the same fields as ForProvider, with the exception + of Identifier and other resource reference fields. The fields that are + in InitProvider are merged into ForProvider when the resource is created. + The same fields are also added to the terraform ignore_changes hook, to + avoid updating them after creation. This is useful for fields that are + required on creation, but we do not desire to update them after creation, + for example because of an external controller is managing them, like an + autoscaler. + properties: + agentName: + description: Name of the agent. + type: string + agentResourceRoleArn: + description: ARN of the IAM role with permissions to invoke API + operations on the agent. + type: string + agentResourceRoleArnRef: + description: Reference to a Role in iam to populate agentResourceRoleArn. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + agentResourceRoleArnSelector: + description: Selector for a Role in iam to populate agentResourceRoleArn. + properties: + matchControllerRef: + description: |- + MatchControllerRef ensures an object with the same controller reference + as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching labels + is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + customerEncryptionKeyArn: + description: ARN of the AWS KMS key that encrypts the agent. + type: string + description: + description: Description of the agent. + type: string + foundationModel: + description: Foundation model used for orchestration by the agent. + type: string + idleSessionTtlInSeconds: + description: Number of seconds for which Amazon Bedrock keeps + information about a user's conversation with the agent. A user + interaction remains active for the amount of time specified. + If no conversation occurs during this time, the session expires + and Amazon Bedrock deletes any data provided before the timeout. + type: number + instruction: + description: Instructions that tell the agent what it should do + and how it should interact with users. + type: string + prepareAgent: + description: Whether to prepare the agent after creation or modification. + Defaults to true. + type: boolean + promptOverrideConfiguration: + description: Configurations to override prompt templates in different + parts of an agent sequence. For more information, see Advanced + prompts. See prompt_override_configuration Block for details. + items: + properties: + overrideLambda: + description: ARN of the Lambda function to use when parsing + the raw foundation model output in parts of the agent + sequence. If you specify this field, at least one of the + prompt_configurations block must contain a parser_mode + value that is set to OVERRIDDEN. + type: string + promptConfigurations: + description: Configurations to override a prompt template + in one part of an agent sequence. See prompt_configurations + Block for details. + items: + properties: + basePromptTemplate: + description: prompt template with which to replace + the default prompt template. You can use placeholder + variables in the base prompt template to customize + the prompt. For more information, see Prompt template + placeholder variables. + type: string + inferenceConfiguration: + description: Inference parameters to use when the + agent invokes a foundation model in the part of + the agent sequence defined by the prompt_type. For + more information, see Inference parameters for foundation + models. See inference_configuration Block for details. + items: + properties: + maxLength: + description: Maximum number of tokens to allow + in the generated response. + type: number + stopSequences: + description: List of stop sequences. A stop + sequence is a sequence of characters that + causes the model to stop generating the response. + items: + type: string + type: array + temperature: + description: Likelihood of the model selecting + higher-probability options while generating + a response. A lower value makes the model + more likely to choose higher-probability options, + while a higher value makes the model more + likely to choose lower-probability options. + type: number + topK: + description: Number of top most-likely candidates, + between 0 and 500, from which the model chooses + the next token in the sequence. + type: number + topP: + description: Top percentage of the probability + distribution of next tokens, between 0 and + 1 (denoting 0% and 100%), from which the model + chooses the next token in the sequence. + type: number + type: object + type: array + parserMode: + description: 'Whether to override the default parser + Lambda function when parsing the raw foundation + model output in the part of the agent sequence defined + by the prompt_type. If you set the argument as OVERRIDDEN, + the override_lambda argument in the prompt_override_configuration + block must be specified with the ARN of a Lambda + function. Valid values: DEFAULT, OVERRIDDEN.' + type: string + promptCreationMode: + description: 'Whether to override the default prompt + template for this prompt_type. Set this argument + to OVERRIDDEN to use the prompt that you provide + in the base_prompt_template. If you leave it as + DEFAULT, the agent uses a default prompt template. + Valid values: DEFAULT, OVERRIDDEN.' + type: string + promptState: + description: 'Whether to allow the agent to carry + out the step specified in the prompt_type. If you + set this argument to DISABLED, the agent skips that + step. Valid Values: ENABLED, DISABLED.' + type: string + promptType: + description: 'Step in the agent sequence that this + prompt configuration applies to. Valid values: PRE_PROCESSING, + ORCHESTRATION, POST_PROCESSING, KNOWLEDGE_BASE_RESPONSE_GENERATION.' + type: string + type: object + type: array + type: object + type: array + skipResourceInUseCheck: + description: Whether the in-use check is skipped when deleting + the agent. + type: boolean + tags: + additionalProperties: + type: string + description: Key-value map of resource tags. + type: object + x-kubernetes-map-type: granular + type: object + managementPolicies: + default: + - '*' + description: |- + THIS IS A BETA FIELD. It is on by default but can be opted out + through a Crossplane feature flag. + ManagementPolicies specify the array of actions Crossplane is allowed to + take on the managed and external resources. + This field is planned to replace the DeletionPolicy field in a future + release. Currently, both could be set independently and non-default + values would be honored if the feature flag is enabled. If both are + custom, the DeletionPolicy field will be ignored. + See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md + items: + description: |- + A ManagementAction represents an action that the Crossplane controllers + can take on an external resource. + enum: + - Observe + - Create + - Update + - Delete + - LateInitialize + - '*' + type: string + type: array + providerConfigRef: + default: + name: default + description: |- + ProviderConfigReference specifies how the provider that will be used to + create, observe, update, and delete this managed resource should be + configured. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + publishConnectionDetailsTo: + description: |- + PublishConnectionDetailsTo specifies the connection secret config which + contains a name, metadata and a reference to secret store config to + which any connection details for this managed resource should be written. + Connection details frequently include the endpoint, username, + and password required to connect to the managed resource. + properties: + configRef: + default: + name: default + description: |- + SecretStoreConfigRef specifies which secret store config should be used + for this ConnectionSecret. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + metadata: + description: Metadata is the metadata for connection secret. + properties: + annotations: + additionalProperties: + type: string + description: |- + Annotations are the annotations to be added to connection secret. + - For Kubernetes secrets, this will be used as "metadata.annotations". + - It is up to Secret Store implementation for others store types. + type: object + labels: + additionalProperties: + type: string + description: |- + Labels are the labels/tags to be added to connection secret. + - For Kubernetes secrets, this will be used as "metadata.labels". + - It is up to Secret Store implementation for others store types. + type: object + type: + description: |- + Type is the SecretType for the connection secret. + - Only valid for Kubernetes Secret Stores. + type: string + type: object + name: + description: Name is the name of the connection secret. + type: string + required: + - name + type: object + writeConnectionSecretToRef: + description: |- + WriteConnectionSecretToReference specifies the namespace and name of a + Secret to which any connection details for this managed resource should + be written. Connection details frequently include the endpoint, username, + and password required to connect to the managed resource. + This field is planned to be replaced in a future release in favor of + PublishConnectionDetailsTo. Currently, both could be set independently + and connection details would be published to both without affecting + each other. + properties: + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - name + - namespace + type: object + required: + - forProvider + type: object + x-kubernetes-validations: + - message: spec.forProvider.agentName is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.agentName) + || (has(self.initProvider) && has(self.initProvider.agentName))' + - message: spec.forProvider.foundationModel is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.foundationModel) + || (has(self.initProvider) && has(self.initProvider.foundationModel))' + status: + description: AgentStatus defines the observed state of Agent. + properties: + atProvider: + properties: + agentArn: + description: ARN of the agent. + type: string + agentId: + description: Unique identifier of the agent. + type: string + agentName: + description: Name of the agent. + type: string + agentResourceRoleArn: + description: ARN of the IAM role with permissions to invoke API + operations on the agent. + type: string + agentVersion: + description: Version of the agent. + type: string + customerEncryptionKeyArn: + description: ARN of the AWS KMS key that encrypts the agent. + type: string + description: + description: Description of the agent. + type: string + foundationModel: + description: Foundation model used for orchestration by the agent. + type: string + id: + description: Unique identifier of the agent. + type: string + idleSessionTtlInSeconds: + description: Number of seconds for which Amazon Bedrock keeps + information about a user's conversation with the agent. A user + interaction remains active for the amount of time specified. + If no conversation occurs during this time, the session expires + and Amazon Bedrock deletes any data provided before the timeout. + type: number + instruction: + description: Instructions that tell the agent what it should do + and how it should interact with users. + type: string + prepareAgent: + description: Whether to prepare the agent after creation or modification. + Defaults to true. + type: boolean + promptOverrideConfiguration: + description: Configurations to override prompt templates in different + parts of an agent sequence. For more information, see Advanced + prompts. See prompt_override_configuration Block for details. + items: + properties: + overrideLambda: + description: ARN of the Lambda function to use when parsing + the raw foundation model output in parts of the agent + sequence. If you specify this field, at least one of the + prompt_configurations block must contain a parser_mode + value that is set to OVERRIDDEN. + type: string + promptConfigurations: + description: Configurations to override a prompt template + in one part of an agent sequence. See prompt_configurations + Block for details. + items: + properties: + basePromptTemplate: + description: prompt template with which to replace + the default prompt template. You can use placeholder + variables in the base prompt template to customize + the prompt. For more information, see Prompt template + placeholder variables. + type: string + inferenceConfiguration: + description: Inference parameters to use when the + agent invokes a foundation model in the part of + the agent sequence defined by the prompt_type. For + more information, see Inference parameters for foundation + models. See inference_configuration Block for details. + items: + properties: + maxLength: + description: Maximum number of tokens to allow + in the generated response. + type: number + stopSequences: + description: List of stop sequences. A stop + sequence is a sequence of characters that + causes the model to stop generating the response. + items: + type: string + type: array + temperature: + description: Likelihood of the model selecting + higher-probability options while generating + a response. A lower value makes the model + more likely to choose higher-probability options, + while a higher value makes the model more + likely to choose lower-probability options. + type: number + topK: + description: Number of top most-likely candidates, + between 0 and 500, from which the model chooses + the next token in the sequence. + type: number + topP: + description: Top percentage of the probability + distribution of next tokens, between 0 and + 1 (denoting 0% and 100%), from which the model + chooses the next token in the sequence. + type: number + type: object + type: array + parserMode: + description: 'Whether to override the default parser + Lambda function when parsing the raw foundation + model output in the part of the agent sequence defined + by the prompt_type. If you set the argument as OVERRIDDEN, + the override_lambda argument in the prompt_override_configuration + block must be specified with the ARN of a Lambda + function. Valid values: DEFAULT, OVERRIDDEN.' + type: string + promptCreationMode: + description: 'Whether to override the default prompt + template for this prompt_type. Set this argument + to OVERRIDDEN to use the prompt that you provide + in the base_prompt_template. If you leave it as + DEFAULT, the agent uses a default prompt template. + Valid values: DEFAULT, OVERRIDDEN.' + type: string + promptState: + description: 'Whether to allow the agent to carry + out the step specified in the prompt_type. If you + set this argument to DISABLED, the agent skips that + step. Valid Values: ENABLED, DISABLED.' + type: string + promptType: + description: 'Step in the agent sequence that this + prompt configuration applies to. Valid values: PRE_PROCESSING, + ORCHESTRATION, POST_PROCESSING, KNOWLEDGE_BASE_RESPONSE_GENERATION.' + type: string + type: object + type: array + type: object + type: array + skipResourceInUseCheck: + description: Whether the in-use check is skipped when deleting + the agent. + type: boolean + tags: + additionalProperties: + type: string + description: Key-value map of resource tags. + type: object + x-kubernetes-map-type: granular + tagsAll: + additionalProperties: + type: string + description: Map of tags assigned to the resource, including those + inherited from the provider default_tags configuration block. + type: object + x-kubernetes-map-type: granular + type: object + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: |- + LastTransitionTime is the last time this condition transitioned from one + status to another. + format: date-time + type: string + message: + description: |- + A Message containing details about this condition's last transition from + one status to another, if any. + type: string + observedGeneration: + description: |- + ObservedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + type: integer + reason: + description: A Reason for this condition's last transition from + one status to another. + type: string + status: + description: Status of this condition; is it currently True, + False, or Unknown? + type: string + type: + description: |- + Type of this condition. At most one of each condition type may apply to + a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + observedGeneration: + description: |- + ObservedGeneration is the latest metadata.generation + which resulted in either a ready state, or stalled due to error + it can not recover from without human intervention. + format: int64 + type: integer + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {}